Back

Is there a way to automatically create a document if it doesn't exist, or update it if it does?

  • 0
  • Databases
  • GraphQL
  • General
  • Web
debashish
25 Oct, 2023, 20:30

Currently, I need to make two separate API calls: one to check if the document exists in the collection, and another to either create it if it doesn't exist or update it if it does. Is it possible to streamline this process so that a single API call can handle both scenarios: creating the document if it doesn't exist or updating it if it does?"

TL;DR
The user is asking if there is a way to automatically create a document if it doesn't exist, or update it if it does. The support team suggests creating a feature request on GitHub and exploring the possibility of adding this feature in a later release. They also mention the option of creating an Appwrite function to streamline the process. Currently, the user needs to make two separate API calls to check if the document exists and either create or update it. No solution is provided in the thread.
Drake
25 Oct, 2023, 20:35

You're asking for an upsert API/method. We don't have that at the moment.

You could try creating an Appwrite function that wraps the logic

Tessa
25 Oct, 2023, 20:36

Duplicate question here as well: https://discord.com/channels/564160730845151244/1138110897013915709 in case it’s helpful

Torsten Dittmann
25 Oct, 2023, 20:40

Might be something to explore. We had this question already multiple times iirc

debashish
26 Oct, 2023, 03:26

Thanks for the confirmation. I will find the workaround. but reallly a needed inbuilt feaure. hope to see it in later release of appwrite.

Drake
1 Nov, 2023, 15:05

feel free to create a feature request issue on github

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more