-
-
Notifications
You must be signed in to change notification settings - Fork 154
feat: add upsert object handler #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/routes/object/upsertObject.ts
Outdated
}) | ||
} | ||
|
||
const objectResponse = await postgrest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the upsert function of postgrest? Saves us a API call
Hi Ankit, thank you so much for the PR! Looking at the code, once you use the What do you think about adding upsert functionality into createObject itself? By default, we won't upsert but if there is a header called Another advantage of this, we wont need to create a new API endpoint. The API endpoint |
Right, I was thinking of the same thing about having upsert inside |
Thanks Ankit :)
I learnt this the hard way as well haha #22 |
Also can you merge in the changes from master Ankit? I just made some changes to the createObject file. |
Sure. @inian I was trying the upsert now, for some reason it doesn't work, looked up the documentation in postgrest-js
I get the same error
|
Apparently, the postgrest client wasn't exposing the upsert method in query builder, I upgraded the package and using it worked. I was trying out the deprecated insert operation with upsert sadly. |
I messed up the merge somehow, closing this PR and creating another one. |
What kind of change does this PR introduce?
Feature
What is the current behavior?
The create object handler throws duplicate not allowed error, if object already exists
What is the new behavior?
Adds route
which inserts an object if it doesn't exist. If it does exist it updates the object with new file.
Screen recording