Skip to main content

Own data

An app has no database of its own. To keep records (reviewed orders, incidents, settings) it uses models: data collections that ConsulPoint stores for it.

What a model is​

ElementContent
NameIdentifier of the collection, lowercase with hyphens (reviewed-order). Up to 60 characters. It cannot be changed later
LabelHuman-readable name
DescriptionWhat the collection stores
JSON SchemaShape of each record (optional)
Strict validationIf on, records that do not match the schema are rejected

Models are defined in the app's Models tab, with Add Model. They must exist before the app tries to use them.

In an Installed app, the models are defined by whoever published it and cannot be modified.

Who owns the data​

  • The data belongs to each organization: one organization never sees another's.
  • Within the organization, everyone who uses the app sees the same records. There is no per-user separation.
  • When you uninstall an app from the catalog, its data is deleted and is not recovered if you reinstall it.
  • When you delete a model, all its records are deleted.

Read and save​

All paths start from /mini-apps/{miniAppId}/models/{name}/data.

OperationMethod and pathNotes
ListGET …/data?limit=Up to 500 per page (25 by default). The response includes bookmark to request the next page
Read oneGET …/data/{id}
CreatePOST …/dataThe body is the record
UpdatePUT …/data/{id}Body: { "data": { … }, "_rev": "…" }
DeleteDELETE …/data/{id}?rev=…
Create and update a record
const base = `/mini-apps/${miniAppId}/models/reviewed-order/data`;

const created = await sessionFetch(base, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ order: 'P-1042', status: 'confirmed' }),
}).then(r => r.json());

await sessionFetch(`${base}/${created._id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ data: { status: 'exported' }, _rev: created._rev }),
});

Each record includes _id and _rev. _rev is the record's version and must be sent when updating or deleting.

Responses to handle​

ResponseMeaningWhat to do
409Someone else modified the record firstRead it again and retry
422The record does not match the schema (with strict validation)Check the fields listed in the response
400_rev is missing on updateSend the version you read

Best practices​

Always use the identifier

Data paths use the app identifier received in miniAppId, never its access path.

Unexpected fields

To reject fields that are not in the schema, declare "additionalProperties": false in the JSON Schema itself.

Lists

Lists do not support filters or sorting. For large collections, read page by page and filter in the app.