Back

Increase/decrease document attribute (Atomic operation)

  • 1
  • Databases
kurosh
15 Mar, 2023, 15:31

I need increase document attribute for my project and I found https://github.com/appwrite/appwrite/issues/3905 and https://github.com/utopia-php/database/pull/217 but I know increment/decrease API isn't available yet. Do you have any workaround?

TL;DR
The user is asking for a workaround to increase/decrease a document attribute. The support team suggests creating a new data point and updating the document with the new data using looping. They mention that incrementing should be an atomic operation. The support team also mentions that the feature is highly requested and they will check for any workarounds or updates. The user shares their open-source project and mentions that they used Firebase services but would like to use Appwrite. The support team asks for more details about the use case to provide specific workarounds. No solution is provided in this thread.
joeyouss
15 Mar, 2023, 15:53

Hi kurosh, yes this has been a highly requested feature, let me talk to my team and fix you up with any workarounds if possible

joeyouss
15 Mar, 2023, 16:03

Also

joeyouss
15 Mar, 2023, 16:04

It would be great if you could share a bit more about your usecase i.e. what you are trying to do so maybe we could discuss specific workarounds

kurosh
15 Mar, 2023, 16:19

I have this open source project https://github.com/mondora/cycletowork that I used firebase services for backend and I like to used appwrite

kurosh
15 Mar, 2023, 16:24

For example each cyclist has a some of km and CO2 and every time they biking we have to increase those values

kurosh
15 Mar, 2023, 16:35

that increase have to be atomic when there are in challenge and each company have some cyclist and we have to increase those values

joeyouss
15 Mar, 2023, 16:52

Awesome, thank you for elaborating

joeyouss
15 Mar, 2023, 18:12

So what you could do is as a workaround that

joeyouss
15 Mar, 2023, 18:12

You could create a new data point and update the document https://appwrite.io/docs/client/databases?sdk=web-default#databasesUpdateDocument with the new data, they could use looping for this so instead of incrementing or decrementing it could be an update operation given that they are processing not more than 120 requests in every 1 minutes.

joeyouss
15 Mar, 2023, 18:13

Maybe a function which does the updation for you and does all the calculation .

joeyouss
15 Mar, 2023, 18:14

We do not have a fix currently for this but it would be great if you upvote the issue linked to incrementation and I’ll ask my team if there’s any timeline regarding this!

kurosh
15 Mar, 2023, 20:25

unfortunately this workaround is not work for me , I hope you implement this feature as soon as possible

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