Back

Updating an Attribute of Type Array With a New Element

  • 1
  • Databases
  • Web
DerrickML
28 Nov, 2023, 14:46

How can I update an attribute of array type by appending a new item?

TL;DR
The user wants to know how to update an attribute of type array by appending a new item. They are also concerned about race conditions when doing a get and update. There is a suggestion to create a function to handle the update, but it would require more work. There is no solution provided in the support thread.
Kenny
28 Nov, 2023, 14:49

I wonder if you'd need to get the array and add a new element then update the record with the new array.

DerrickML
28 Nov, 2023, 14:54

was my first thought. Limiting requests to appwrite is my goal. As for coding, it feels like I’m writing a novel that never ends!

Kenny
28 Nov, 2023, 15:01

For sure, I'd be interested to see what the best answer is. Other than what I've put above, to limiting your calls in your frontend, you can setup a function that does this for you, but that would obviously be more work /:

WhiteWalker72
28 Nov, 2023, 15:59

One issue with doing a get and then an update is also that you could run into race conditions. I would love to know if there is better way of doing this

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