Can't get relations from db.update
This is the code I use to retrieve a user:
The problem is when the user updates (db.update) I can not use the with: {} and return the users buildings. I can do another query after the update and use the data it gets, but it's yet another lookup. Any thoughts?
5 Replies
Can you please put a minimal example on https://drizzle.run/ ?
It might be easier to just take a look on what you're trying to accomplish. If I get it correctly, the error happens once user has a building associated with him, which might suggest a problem with how you've setup your relations (though I'm not sure)
Drizzle Run
Drizzle Run
If I did it right, that should work
and show what I mean
I think that the
with
joins are only supported when using query syntax. Such example isn't visible in the docs, so an educated guess is that returning is scoped to updated/inserted row.
One thing to figure out is whether postgres itself supports RETURNING
from joined tables - at the end of the day drizzle is always compiled to the SQL. If SQL supports it, then it's half of the success.Drizzle ORM - Update
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
If it isn't possible, I would just wrap it within a transaction and perform the separate query on it's own