Records your Ownbox keeps

3 entries

Markdown

m.keep

Hand your Ownbox one record to keep.

Signature
m.keep(kind, key, fields, person=None)
Example · Inside a job
ava = m.person("email", "ava@example.com", name="Ava Reyes")
m.keep("quote", "q-1001", {"total": 450, "status": "sent"}, person=ava)

Your Ownbox keeps the data, never the machine. Each kind of record is declared in machine.yaml under records:, beside actions:, and a record is a JSON object of at most 16 KB under a key of 1 to 100 characters. The same key again replaces it. person names who it is about, only on a kind declared person: true. A machine keeps at most 10,000 records and 20 MB in all; past either the call is refused, and nothing is cut short.

Needs in machine.yaml
its kind, declared under records in machine.yaml
Returns
{"kept": True}.

m.kept

Read your records back.

Signature
m.kept(kind, key=None, *, limit=50, cursor=None)
Example · Inside a job
quote = m.kept("quote", "q-1001")
page = m.kept("quote", limit=20)
while page["next"]:
    page = m.kept("quote", limit=20, cursor=page["next"])

With a key, that record's fields, or None. Without one, a page of that kind's records, newest first: 50 unless limit says otherwise, and at most 200. Pass next back as cursor for the page after; it is "" at the end.

Needs in machine.yaml
its kind, declared under records in machine.yaml
Returns
The record's fields, or {"records": [{"key", "fields", "person", "updated_at"}], "next"}.

m.drop

Let one record go.

Signature
m.drop(kind, key)
Example · Inside a job
m.drop("quote", "q-1001")

It is gone from your Ownbox. Dropping a key it never kept is not an error.

Needs in machine.yaml
its kind, declared under records in machine.yaml
Returns
{"dropped": True}, or False when there was none.