`pageId` does not exist when inserting, even though it's in the schema

I have the following schema:
export const scrapeStatusEnum = pgEnum("scrape_status", [
"error",
"not-enough-information",
"success",
]);

export const scrapes = pgTable("scrapes", {
id: uuid().defaultRandom().primaryKey(),
...timestamps,

simHash: text().notNull(),
url: text().notNull(),

response: jsonb(),
status: scrapeStatusEnum().notNull(),

metadataId: uuid()
.references(() => metadata.id)
.unique(),
pageId: uuid()
.notNull()
.references(() => pages.id),
});

export const scrapesRelations = relations(scrapes, ({ one }) => ({
metadata: one(metadata, {
fields: [scrapes.metadataId],
references: [metadata.id],
}),
}));
export const scrapeStatusEnum = pgEnum("scrape_status", [
"error",
"not-enough-information",
"success",
]);

export const scrapes = pgTable("scrapes", {
id: uuid().defaultRandom().primaryKey(),
...timestamps,

simHash: text().notNull(),
url: text().notNull(),

response: jsonb(),
status: scrapeStatusEnum().notNull(),

metadataId: uuid()
.references(() => metadata.id)
.unique(),
pageId: uuid()
.notNull()
.references(() => pages.id),
});

export const scrapesRelations = relations(scrapes, ({ one }) => ({
metadata: one(metadata, {
fields: [scrapes.metadataId],
references: [metadata.id],
}),
}));
and a query
await db.insert(scrapes).values({
pageId: page.id,
response: object,
simHash,
url,
status,
});
await db.insert(scrapes).values({
pageId: page.id,
response: object,
simHash,
url,
status,
});
But I get error
error TS2769: No overload matches this call.
Overload 2 of 2, '(values: { status: "error" | "success" | SQL<unknown> | "not-enough-information" | Placeholder<string, any>; url: string | SQL<unknown> | Placeholder<string, any>; ... 6 more ...; metadataId?: string | ... 3 more ... | undefined; }[]): PgInsertBase<...>', gave the following error.
Object literal may only specify known properties, and 'pageId' does not exist in type '{ status: "error" | "success" | SQL<unknown> | "not-enough-information" | Placeholder<string, any>; url: string | SQL<unknown> | Placeholder<string, any>; ... 6 more ...; metadataId?: string | ... 3 more ... | undefined; }[]'.

133 pageId: page.id,
~~~~~~
error TS2769: No overload matches this call.
Overload 2 of 2, '(values: { status: "error" | "success" | SQL<unknown> | "not-enough-information" | Placeholder<string, any>; url: string | SQL<unknown> | Placeholder<string, any>; ... 6 more ...; metadataId?: string | ... 3 more ... | undefined; }[]): PgInsertBase<...>', gave the following error.
Object literal may only specify known properties, and 'pageId' does not exist in type '{ status: "error" | "success" | SQL<unknown> | "not-enough-information" | Placeholder<string, any>; url: string | SQL<unknown> | Placeholder<string, any>; ... 6 more ...; metadataId?: string | ... 3 more ... | undefined; }[]'.

133 pageId: page.id,
~~~~~~
2 Replies
nahtnam
nahtnamOP2mo ago
My auto-complete lists all of these as valid options
No description
nahtnam
nahtnamOP2mo ago
I just updated to the latest drizzle 0.35.1 Downgrading doesnt seem to fix it so I think im doing something wrong Figured it out, one of the properties types mismatched (not pageId)
Want results from more Discord servers?
Add your server