Back

work with array attributes

  • 1
  • Web
OuJson
7 Dec, 2023, 14:42

i have an array attribute in my db and i want to update it by pushing a new value into it. how can i achieve this ??? PLEASE I NEED HELP ! <#1072905050399191082>

TL;DR
The user wants to update an array attribute by pushing a new value into it. One solution is to use two loaders: one to get the existing list from the document and another to push the new value into the array. This can be done by fetching the value and making the changes in the desired programming language, and then pushing the entire new array as an update to the document.
Ryan
7 Dec, 2023, 14:43

The best way that I think to do this would be to fetch the value and do the changes in whichever language you're using and then push the entire new array as an update to the document

OuJson
7 Dec, 2023, 15:02

okay, i'll give it a tru

OuJson
7 Dec, 2023, 15:02

try*

OuJson
7 Dec, 2023, 15:02

Thanks @Ryan

WhiteWalker72
7 Dec, 2023, 15:31

Also if you want to do that while not running into race conditions take a look at: https://discord.com/channels/564160730845151244/1182156887286882324

OuJson
7 Dec, 2023, 18:22

@WhiteWalker72 thanks mate what i did in my case, is creating two loaders one the get the existing list in the Document using the docId in a Query.

OuJson
7 Dec, 2023, 18:23

then an other loader in which i push the new value in the array i've already got and send the new array to the target document with an update action

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