Back

Creating nested relation on a two-way many to one

  • 0
  • Databases
  • Web
  • Cloud
devo_wm
30 Jun, 2024, 22:26

The example provided in the docs here has an example of what looks like a one to many (by passing a nested array of documents)

https://appwrite.io/docs/products/databases/relationships#create-documents

Does this mean to create a one to many, and assuming an arbitrary attribute key name relation_name, would you post a document in the shape of an object or just the id?

psuedo payload in yaml below:

TypeScript
name: My Object Name
random_boolean_attribute: true
relation_name:
  $id: related_object_id

versus

TypeScript
name: My Object Name
random_boolean_attribute: true
relation_name: related_object_id
TL;DR
Developers are asking if nested relations for a two-way many-to-one relationship should be posted with an object containing the ID or just the ID itself. The correct format for the payload is to post the ID directly, without nesting it within an object.
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