logo

DOCUMENT STORE

Storage for your bot's own JSON documents, held on the nandbox server. It lets a bot keep state — carts, profiles, settings, orders — without running a database of its own.
💡 Documents are schemaless. Two documents in the same collection need not have the same fields.

How documents are addressed

Three things together identify a document:
Part
Meaning
app_id
The app the document belongs to.
collection
A grouping you choose — "cart", "profile", "orders".
document_id
The document's id within that collection.
The payload is document, a JSON object.
⚠️ Storing a document whose collection + document_id already exists replaces it entirely. There is no create-versus-update distinction and no partial update — whatever you send becomes the stored document.

Methods

Method
Purpose
Response
setDocument
Create or replace a document
setDocumentResponse
getDocument
Retrieve one document by id
getDocumentResponse
listDocuments
Query a collection, with filters and paging
listDocumentsResponse
deleteDocument
Delete one document by id
deleteDocumentResponse

Responses

All four arrive on one callback:
SDK
Callback
Java
onDocumentResponse(DocumentResponse response)
JavaScript
onDocumentResponse(response)
Python
on_document_response(self, response)
Read response.method to tell which operation you are looking at — it carries the response method name verbatim, so a single handler can switch on it.

Getting a handle

Each SDK exposes the store as a singleton, and every method takes (api, collection, document_id, …) in that order.
java
DocumentStore store = DocumentStore.getInstance(); store.setDocument(api, "orders", "42", document, reference);
javascript
const store = require('nandbox-bot-api/src/util/DocumentStore') store.setDocument(api, 'orders', '42', document, reference)
python
from nandboxbots.util.DocumentStore import DocumentStore store = DocumentStore.get_instance() store.set_document(api, "orders", "42", document, reference)
setDocumentgetDocumentlistDocumentsdeleteDocument