Replies: 4 comments 5 replies
-
Trying this approach:
This returns:
|
Beta Was this translation helpful? Give feedback.
-
The answer depends on whether
Can you clarify which is it, please? |
Beta Was this translation helpful? Give feedback.
-
@elprans probably the first one. Let's say I want to insert
but as I understand that can be done in a single query. If Person's has a unique property (like .fullname), then it's easy with UNLESS CONFLICT. But what if there is no unique fields? That's where I'm trying to employ ".id" field in a client code as an indicator whether entry exists or it should be created. Not sure I answered your question, but hopefully clarified a bit. |
Beta Was this translation helpful? Give feedback.
-
Any solutions for this? I feel like this is going to be pretty common case, so would be nice to understand how to implement this upsert logic properly. |
Beta Was this translation helpful? Give feedback.
-
How to write a single query for the conditional insert/update depending whether .id field is provided?
The use case is some nested update and nested object can be either existing (has .id) or new one (in this case I need to create one).
I tried to use
UNLESS CONFLICT ON .id
, but that returnscannot assign to id
andconsider enabling the "allow_user_specified_id" configuration parameter to allow setting custom object ids
error (which makes sense).Beta Was this translation helpful? Give feedback.
All reactions