I’m have created a query with drizzle-orm and having an issue to debug it
const results = db.query.contract_opgc.findMany({
columns: {
contract_id: true,
....
},
extras: {
totalCount: sql<number>`COUNT(*) OVER()`.as('totalCount'),
},
where: (contract, { eq, and }) => and(eq(contract.country_code, countryCode)),
with: {
item: {
columns: {
item_type_code: true,
},
},
},
I seems like there an issue with item and wrong table name but I think it’s correct. How I can have this query as plain before processing by drizzle orm
Also I have added on top of this
export const contractRelations = relations(item, ({ one }) => ({
contract: one(contract, {
fields: [item.item_gid, item.item_country_code],
references: [contract.item_gid, contract.country_code],
}),
}));