Back

Database Node.js Server API - UpdateDocument function

  • 0
  • Databases
  • REST API
  • Web
  • Cloud
n1klaus
18 Apr, 2024, 11:28

Is there a way to add items to an array in a relationship?

I am currently trying this where tasks are a One To Many relationship attribute represented as an array const item = await databases .updateDocument([DATABASE_ID], [collection_id], [documentId], { tasks: [taskId] }) When I try this I only get that item added to the array and previous additions removed.

TL;DR
Developers are unable to directly add an item to an array in the updateDocument function. To do so, they must get the array value, append the desired item, and then update the document. The issue seems to be removing previous additions when adding a new item to the array.
darShan
18 Apr, 2024, 11:38

i dont think adding an item to an array is possible directly atm. you must get the array value, append your item and then update the doc.

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