-
When using the drizzle plugin I get export const users = pgTable("users", {
id: serial("id").primaryKey(),
name: text("name").notNull(),
});
export const usersRelations = relations(users, ({ one, many }) => ({
posts: many(posts),
}));
export const posts = pgTable("posts", {
id: serial("id").primaryKey(),
content: text("content").notNull(),
authorId: integer("author_id").references(() => users.id),
});
export const postsRelations = relations(posts, ({ one, many }) => ({
author: one(users, { fields: [posts.authorId], references: [users.id] }),
})); and this is what I do: const UserRef = schemaBuilder.drizzleObject("users", {
name: "User",
fields: (t) => ({
id: t.exposeInt("id"),
name: t.exposeString("name"),
}),
}); do you have any hint at what I'm doing wrong? Thank you so much! |
Beta Was this translation helpful? Give feedback.
Answered by
hayes
Dec 31, 2024
Replies: 1 comment 2 replies
-
Are you importing the file that defines user? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This error happens when a field references a type that hasn't been implemented. If you are implementing the type (which it looks like you are) I would double check you are importing the file where it's implemented before calling builder.toSchema