Skip to main content

Read

Read Resource

This entrypoint returns a target resource.

  • GET /{base_url}/:id

Parameters

NameTypeInDescriptionDefault
idstringparamResource identifier; required
include_permissionsbooleanqueryWhether to include document permissionstrue
try_listbooleanqueryWhether to attempt to retrieve the resource if not allowedtrue

Example

request

curl \
-H "Accept: application/json" \
https://example.com/users/5d6ede6a0ba62570afcedd3b?try_list=true&include_permissions=false

response

Status: 200
{
"_id": "5d6ede6a0ba62570afcedd3b",
"name": "Andrew Jackso",
"address": "5d6ede6a0ba62570afcedd3a",
"roles": ["user"],
"creditBalance": 100,
"loginDate": "2022-02-22T02:02:22.679Z"
}

Read Resource - Advanced

This entrypoint returns a target resource that includes selective data fields.

  • POST /{base_url}/__query/:id
  • The suffix __query can be configured using a model option, as demonstrated below:
    modelRouter.set('queryPath', '_queryable_');

Parameters

NameTypeInDescriptionDefault
idstringparamResource identifier; required
selectobject │ array[string]bodyDocument fields to include or exclude
populatearray[string] │ array[object]bodyDocument fields to populate
options.includePermissionsbooleanbodyWhether to include document permissionstrue
options.tryListbooleanbodyWhether to attempt to retrieve the resource if not allowedtrue
options.populateAccess'list' │ 'read'bodyThe access level to use in populate methodread
skimbooleanqueryWhether to bypass Document-level permissions checksfalse

Example

request

curl \
-X POST \
-H "Accept: application/json" \
https://example.com/users/__query/5d6ede6a0ba62570afcedd3b \
-d '{
"select": ["name", "address"],
"populate": ["address"],
"options": {
"includePermissions": true,
"tryList": true,
"populateAccess": "list"
}
}'

response

Status: 200
{
"_id": "5d6ede6a0ba62570afcedd3b",
"name": "Andrew Jackso",
"address": {
"city": "Seattle",
"country": "USA"
},
"_permissions": {
"edit": false
}
}