Prøxïmïty
DTDrizzle Team
•Created by Prøxïmïty on 6/20/2024 in #help
$inferSelect and $inferInsert doesn't return table types
6 replies
DTDrizzle Team
•Created by Prøxïmïty on 5/8/2024 in #help
Can anyone help with this issue: There is not enough information to infer relation
I defined the relationships on both sides and still no avail.
anyone see anything off here, im at my last straw
export const agencies = pgTable("agencies", {
id: varchar("id", { length: 30 })
.$defaultFn(() => generateId("agency"))
.primaryKey(),
name: varchar("name", { length: 255 }).notNull(),
parentId: varchar("parent_id", { length: 30 }).references(
(): any => agencies.id,
{
onDelete: "cascade",
}
),
agencyLogoUrl: text("agency_logo_url"),
})
export const agenciesRelations = relations(agencies, ({ one, many }) => ({
parent: one(agencies, {
fields: [agencies.parentId],
references: [agencies.id],
relationName: "parentAgency",
}),
subAgencies: many(agencies, {
relationName: "parentAgency",
}),
sidebarOptions: many(sidebarOptions, {
relationName: "agency-sidebar-options",
}),
}))
export const sidebarOptions = pgTable("sidebar_options", {
id: varchar("id", { length: 30 })
.$defaultFn(() => generateId("sidebar_option"))
.primaryKey(),
agencyId: varchar("agency_id", { length: 30 }).references(
() => agencies.id,
{
onDelete: "cascade",
}
),
name: varchar("name", { length: 255 }).notNull(),
icon: varchar("icon", { length: 255 }).default("Menu").notNull(),
link: text("link").default("#").notNull(),
description: text("description").default(""),
order: integer("order").default(1).notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").default(sql
current_timestamp),
deletedAt: timestamp("deleted_at"),
})
export const sidebarOptionsRelations = relations(sidebarOptions, ({ one }) => ({
agency: one(agencies, {
fields: [sidebarOptions.agencyId],
references: [agencies.id],
relationName: "agency-sidebar-options",
}),
}))
1 replies
DTDrizzle Team
•Created by Prøxïmïty on 9/21/2023 in #help
Cannot read properties of undefined (reading \'columns\')
I tired using relational queries
const bookmarkdb = drizzle(pool, { schema });
const resources = await bookmarkdb.query.bookmark.findFirst({
with: {
resource: true,
},
});
4 replies
DTDrizzle Team
•Created by Prøxïmïty on 9/19/2023 in #help
HELP: Key columns "resource_id" and "id" are of incompatible types: text and integer.
I don't know what to do anymore i've tried all the possible solutions i could think about,
export const bookmarks = pgTable("bookmarks", {
id: serial("id").primaryKey(),
user_id: text("user_id")
.notNull()
.references(() => users.id),
resource_id: text("resource_id")
.notNull()
.references(() => resource.id),
});
export const bookmarkRelations = relations(bookmarks, ({ one }) => ({
resource: one(resource, {
fields: [bookmarks.resource_id],
references: [resource.id],
}),
user: one(users, {
fields: [bookmarks.user_id],
references: [users.id],
}),
}));
export const users = pgTable("user", {
id: text("id").notNull().primaryKey(),
name: text("name"),
email: text("email").notNull(),
emailVerified: timestamp("emailVerified", { mode: "date" }),
image: text("image"),
});
export const userRelations = relations(users, ({ many }) => ({
sharedLinks: many(sharedLinks),
bookmarks: many(bookmarks),
}));
2 replies