Including Related Objects

Including related objects.

In some situations, you may want to return multiple types of related objects in one query.

The following sample collection consists of two columns (owner and subtask) with the pointer-referenced Users and todo collections respectively.


Sample database.

The subtask _id is referred to the _id of the parameter from the same collection; while the owner _id is refer to the parameters from the Users collection of the same database.


curl -X POST \
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" \
  -H "Content-Type: application/json" \
  -d '{"include":"owner"}' \
When the query is executed with an include parameter for the key holding this pointer, the pointer will be expanded to the object:

 "taskName":"Test new code",
 "_createdAt":"2015-04-07 13:17:04.912",
 "_updatedAt":"2015-04-07 14:09:48.573",
   "_createdAt":"2014-11-03 13:25:02.468",
   "_updatedAt":"2015-04-07 13:40:19.956",
   "email":"[email protected]"
You can also do multi-level includes using dot notation:

curl -X POST \
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" \
  -H "Content-Type: application/json" \
  -d '{"include":"owner.subtask"}' \
You can also execute a query with multiple fields included. Pass a comma-separated list of keys as the include parameter:

curl -X POST \
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" \
  -H "Content-Type: application/json" \
  -d '{"include":"owner,subtask"}' \
To update the collection, provide the X-Appery-Session-Token parameter and _id of the referenced collection entry you would like to update.

To delete the pointer-referenced entry from the collection, also provide the X-Appery-Session-Token and _id of the referenced collection entry you would like to delete. The response is empty object.