maupiszon
maupiszon
DTDrizzle Team
Created by maupiszon on 9/24/2023 in #help
How to use Query with relations ?
Hello, I'm encountering an issue when trying to execute a query with relations in my code. Here's the function I'm working with:
async getOneWithRelations(id: string): Promise<AlbumWithRelationsResponse> {
const { db, withErrorHandling } = this;
return withErrorHandling(async () => {
const { uuid } = uuidSchema.parse({ uuid: id });
const result = await db.query.albumTable.findFirst({
where: eq(albumTable.id, uuid),
with: {
images: true,
},
});
console.log(result);
return result;
});
}
async getOneWithRelations(id: string): Promise<AlbumWithRelationsResponse> {
const { db, withErrorHandling } = this;
return withErrorHandling(async () => {
const { uuid } = uuidSchema.parse({ uuid: id });
const result = await db.query.albumTable.findFirst({
where: eq(albumTable.id, uuid),
with: {
images: true,
},
});
console.log(result);
return result;
});
}
When I run this function, I receive the following error:
TypeError: Cannot read properties of undefined (reading 'referencedTable')
TypeError: Cannot read properties of undefined (reading 'referencedTable')
I suspect there might be an issue with my schema. Could you help me identify and resolve the problem?
13 replies