TypeError: Cannot read properties of undefined (reading 'referencedTable')

Here is the relational query that I'm trying to execute (Turso SQLite):
const result = db.query.product
      .findMany({
        where: (product) => inArray(product.id, keys),
        with: {
          seller: true,
        },
      })
      .execute();

Here is the schema:
export const product = sqliteTable(
  "product",
  {
    id: text("id").notNull().primaryKey(),
    ...
    sellerId: text("sellerId")
      .notNull()
      .references(() => user.id),
   },
  (product) => ({
    sellerIdx: index("sellerIdx").on(product.sellerId),
  }),
);

export const user = sqliteTable(
  "user",
  {
   
    id: text("id").notNull().primaryKey(),
}).notNull(),
...
  },
  (user) => ({
    nameIdx: uniqueIndex("nameIdx").on(user.name),
  }),
);

export const productRelations = relations(product, ({ one, many }) => ({
  seller: one(user, {
    fields: [product.sellerId],
    references: [user.id],
  }),
}));

export const userRelations = relations(user, ({ one, many }) => ({
  products: many(product),
}));

Everytime I run relational query "with:{seller:true}" it throws error. In Drizzlekit studio, the product references seller just fine. What's wrong?
Was this page helpful?