After creating data buckets, you can use them through the data
templating helpers or by directly referencing them in a route response or CRUD route.
Two helpers are available: data
and dataRaw
. They work in a similar way to the body
and bodyRaw
helpers.
They can be used anywhere templating helpers are supported: body editor, files, headers keys and values, etc., and allow you to partially reuse your data bucket content and compose dynamic responses body easily.
Both helpers support retrieving the data bucket by its unique ID or name. It also allows you to retrieve only part of the data bucket using an optional object path:
Copy
💡 To retrieve data at a specific path, the content of the data bucket must be valid JSON.
Head over to the data helpers' documentation to see more examples.
A setData
helper is available to set the content of a data bucket programmatically. It can be used anywhere templating helpers are supported.
This helper is useful when you want to update the content of a data bucket, push a new value to an array, delete a property, increment or decrement a number, or invert a boolean:
Copy
💡 To set data at a specific path, the content of the data bucket must be valid JSON.
Head over to the setData
helper documentation to see more examples.
When creating a CRUD route you must link a data bucket. This feature allows you to serve and manipulate the data bucket content depending on the CRUD operations. The CRUD routes follow usual REST conventions: GET /resources
, POST /resources
, PUT /resources/:id
, DELETE /resources/:id
, etc.
Head over to the dedicated CRUD routes documentation to learn more about this feature.
A data bucket can also be directly linked to a route response. Linking a data bucket will serve the generated data bucket content "as-is".
To link a data bucket to a route response, choose "Data" in the body selector and select your data bucket.
A data bucket can also store a JSON schema. This schema can be used in the rules system, using the "valid JSON schema" operator to validate the targeted property using ajv.
To store a JSON schema in a data bucket, create a new data bucket and paste your JSON schema in the content editor. The schema must be a valid JSON object:
Copy{ "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "number" } }, "required": ["name", "age"] }
You will then be able to reference this full schema in a rule's value field (e.g. dataBucketNameOrId
), or a specific schema's property using the object-path syntax (e.g. dataBucketNameOrId.name
).