Related object is not typed correctly
I have the following schema
And I am querying like this
cat is of type
I was expecting it to be typed correctly
export const menus = pgTable('menus', {
id: uuid('id').primaryKey(),
name: varchar('name', { length: 256 }).notNull(),
});
// categories
export const categories = pgTable('categories', {
id: uuid('id').primaryKey(),
name: varchar('name', { length: 256 }).notNull(),
menuId: uuid('menu_id').references(() => menus.id),
});
export const menuCategories = relations(menus, ({ many, one }) => {
return {
categories: many(categories)
};
});export const menus = pgTable('menus', {
id: uuid('id').primaryKey(),
name: varchar('name', { length: 256 }).notNull(),
});
// categories
export const categories = pgTable('categories', {
id: uuid('id').primaryKey(),
name: varchar('name', { length: 256 }).notNull(),
menuId: uuid('menu_id').references(() => menus.id),
});
export const menuCategories = relations(menus, ({ many, one }) => {
return {
categories: many(categories)
};
});And I am querying like this
async function main(){
const res = await db.query.menus.findMany({
with:{
categories:true
}
})
const cat = res[0].categories[0]
}async function main(){
const res = await db.query.menus.findMany({
with:{
categories:true
}
})
const cat = res[0].categories[0]
}cat is of type
{
[x:string]:any
}{
[x:string]:any
}I was expecting it to be typed correctly