Rank 2: Process
Can i add or remove one item from array over the simple code for update docment?
Votes
0
Replies
9
Participants
Unknown
Messages
10
Rank 2: Process
Can i add or remove one item from array over the simple code for update docment?
Same as any other array, it's not possible at the moment.
Would you have any suggestions on how to add/remove to an array without bumping into race conditions?
Don't use arrays 😅
So there is basically no way to manage this then?
I'm mostly asking this because I have to increase a counter but then only way to do so is to get the document and update it with a higher count which wouldn't work because of race conditions.
Would it be possible to use an appwrite function and mark it as sync somehow so it will execute once the previous execution is done?
For that counter, I would implement a sort of locking mechanism using unique indexes or something like that. For example, let's say I have a likes attribute on a collection. Id create a likesLocks collection. When updating the like, I would
So what would happen when two parts of the code try to update the like count in this case? The second execution will try to create the lock while the lock already exists? So then the second execution will fail and has to retry until succeeding?
I guess that could work 🤔
Rank 2: Process
so when i want to update the array relationship. How can i do for this?
Rank 2: Process
and when i create new document with having the related collection, is I just add the id of related document to array?
You could do something like Steven suggested: