Skip to main content

Child Of Field in Collections

Child of field in collections allows you to bind two fields of different collections in a parent-child relation. When data gets added in the parent field, it automatically gets reflected in the child field as well.


How to add a "Child Of" field?

For detailed explanation, we are using the example of creating a database for customer orders.

1. Create a Parent Collection

The first step is to create required collections that you want to bind in parent-child relation. As per the example we are using, we have created a parent collection named "Customers".

DrapCode Builder Collection Field

2. Create a Child Collection

Now create a new collection that would be the child collection. As per the example, we have created a child collection named "Orders".

DrapCode Builder Collection Field

3. Create a Field for Order ID in Child Collection

Add a text field in the Orders collection for adding different order IDs.

DrapCode Builder Collection Field

4. Create Fields in the Parent Collection

Now add the following fields in the parent collection, "Customers":

  • Text field: A text field named Customer Name is added in the parent collection, "Customers".

    DrapCode Builder Collection Field
  • Reference field: A reference field is created in the parent collection in reference with the child collection. In the example below, the reference field is named as "All Orders". It will allow the reference field to automatically get data entered in the Order ID field of the child collection, "Orders".

    DrapCode Builder Collection Field

5. Create a "Child Of" Field in the Child Collection

Now open the child collection and add a "Child Of" field in it.

DrapCode Builder Collection Field

To successfully create a "Child Of" field, carefully fill all the fields. First, name the field, for example, "Customer" as done in the example below.

Second, select the parent collection whose child is the child collection, for example "Customers" collection.

Third, select the reference field created previously in the parent collection, for example "All Orders" as shown below.

Fourth, select the field that display customers' name.

DrapCode Builder Collection Field

6. Add Data in the Parent Collection

Now manually add data in the parent collection or dynamically bring data using a collection form. In the example below, we have added a customer named "John Doe".

DrapCode Builder Collection Field

As you can see in the example below, there is no data in the "All Orders" field.

DrapCode Builder Collection Field

7. Add Data in the Child Collection

Now manually add data in the parent collection or dynamically bring data using a collection form.

As per the example we've used, an order ID has to be first added. As the second field, "Customer" is a "Child Of" field, it displays the customers created in the parent collection, "Customers", i.e. John Doe.

DrapCode Builder Collection Field

In the example below, we have added two orders for the customer, John Doe.

DrapCode Builder Collection Field

8. Open the Parent Collection

Now as you will open the parent collection you will see that data added in the child collection is getting reflected in the parent collection.

In the example below, now customer named John Doe has 2 orders.

DrapCode Builder Collection Field