Back

Creating children document nesting with pre-existing parent document

  • 0
  • Databases
Enricrivel
4 Apr, 2024, 15:12

My database has a parent collection that relates to a lot of child collections, the parent has a pre existing document created, and i want to create the child document, linking the child to the parent, is it possible to just do something like

TypeScript
let response_data = {
        "child_attr": "child_data"
      };

      const resp = await databases.updateDocument(
        'database_id',
        'parent_collection_id',
        'parent_document_id',
        response_data
      );

i tried doing it this way, and it never returned an error, but also never went to the rest of my function, so it returned:

TypeScript
Return statement missing. return context.res.empty() if no response is expected.
TL;DR
Developers want to create a child document linked to a pre-existing parent document. The code provided updates the parent document instead of creating a new child document. To create a child document, a new method specifically for that is needed.
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