DatumHuePlatform v0.0.24datumhue.com
Contents

handle10 methods, 2 fields

Document

A shared key-value document. On a network document, keys are /-separated paths: writing a key supersedes what the same author wrote under it, so a parent write replaces that author's subtree and leaves other authors' keys.

Obtained from
datumhue.documents.create, datumhue.documents.open_named, datumhue.documents.open, datumhue.documents.communal

The examples on this page start from:

lua
local doc = datumhue.documents.create()

Fields 2

FieldTypeAccessDescription
scopedocuments.Scoperead-onlyWhere the document lives and who shares it.
can_writebooleanread-onlyWhether this handle may write, or is read-only.

Methods 10

Document:collection

methodsuspends
Document:collection(prefix: string, opts: documents.CollectionOptions) -> DocCollection

An append-only view over the prefix: each distinct entry, whether already in the document or written later, reaches on_add exactly once, until max entries have been delivered. Without a schema, values pass through unvalidated and treating them as untrusted stays the caller's job.

Example
local chat = doc:collection("chat/", {
    schema = { text = { type = "string", max_len = 280 } },
    on_add = function(entry)
        print(entry.text) --> hello
    end,
})
chat:add({ text = "hello" })

opts documents.CollectionOptions options 7 keys

KeyTypeDefaultDescription
on_add requiredfun(value: any, meta: documents.CollectionMeta)no defaultFired once per distinct entry, the entries already in the document included, up to max entries.
maxinteger1024Bound on on_add fires. Entries past it still sync and are counted by count(); they just no longer reach on_add.
max_per_authorintegerno bound per authorBound on on_add fires per verified author. Past it that author's further entries no longer reach on_add — they still sync, still count toward count(), and still consume the global max, which applies on top of this. Requires a network-scope document.
sinceintegerentries of any ageObserve only entries written at or after this UNIX-microseconds timestamp. Older entries, already in the document or arriving later, never reach on_add or count().
authorsstring[]every writer's entriesObserve only these writers' entries (identity keys, as meta.author). Requires a network-scope document. Other writers' entries still sync, but never reach on_add or count().
schematable<string, documents.SchemaField>entries pass unvalidatedDeclarative per-entry validation, keyed by field name. An entry that fails — wrong type, out of bounds, a missing required field, or any undeclared field — is dropped whole: it never reaches on_add and never counts. The schema declaration itself is validated here and raises on unknown keys or malformed specs.
on_ackfun(id: string)no defaultFired at most once per entry this handle added (or, on network scope, authored), when a reader acknowledges it via ack. The receipt carries the entry id only — no reader identity, and no proof: it is an anonymous, unauthenticated courtesy signal.

Document:counter

methodsuspends
Document:counter(prefix: string) -> DocCounter

A grow-only counter over the prefix, shared by every holder of the same prefix. No increment counts twice, whether it was made before the counter opened or after.

Example
local likes = doc:counter("likes/")
likes:on_change(function(value)
    print(value) --> 1
end)
likes:increment()

Document:set

method
Document:set(key: string, value: nil | boolean | integer | number | string | table) -> Op

Write a key-value pair. Errors when doc.can_write is false. The write starts immediately; :ready() observes completion or failure.

Example
doc:set("title", "Notes")
doc:set("players/ada", { score = 3, color = "green" }):ready()
print(doc:get("players/ada"):ready().value.score) --> 3

Document:delete

method
Document:delete(key: string) -> Op

Remove a key. Errors when doc.can_write is false. After delete, get returns nil and query_prefix omits the key; subscribers are notified with a nil value.

Document:get

method
Document:get(key: string, opts?: documents.GetOptions) -> DocEntry

Read a key. The result's value and meta are both nil when the key isn't present (or was deleted).

Example
doc:set("title", "Notes"):ready()
local entry = doc:get("title"):ready()
print(entry.value) --> Notes
print(doc:get("missing"):ready().value) --> nil

opts documents.GetOptions options 1 key

KeyTypeDefaultDescription
authorstringthe newest entry across writersRead this writer's entry at the key instead of newest-wins across writers.

Document:query_prefix

method
Document:query_prefix(prefix: string, opts?: documents.QueryOptions) -> DocQuery

Query every key under the prefix, newest per key; the result's entries is {[key] = {value, meta}}.

Example
doc:set("players/ada", 3):ready()
doc:set("players/bo", 5):ready()
local players = doc:query_prefix("players/"):ready()
-- Entries are keyed by the whole key.
print(players.entries["players/bo"].value) --> 5

opts documents.QueryOptions options 3 keys

KeyTypeDefaultDescription
authorstringevery writer's entriesKeep only this writer's entries.
sinceintegerentries of any ageKeep only entries written at or after this UNIX-microseconds timestamp.
beforeintegerno upper boundKeep only entries written before this UNIX-microseconds timestamp (half-open).

Document:delete_prefix

method
Document:delete_prefix(prefix: string) -> Op

Remove the key subtree: on a local document every key under prefix; on a network document the keys this handle's author wrote under it, erased, and the space they took freed, everywhere the document syncs, while keys other authors wrote there stay. Subscribers are notified with nil values. Errors when doc.can_write is false.

Document:subscribe

methodsuspends
Document:subscribe(prefix: string, callback: fun(key: string, value: any, meta: documents.Meta)) -> Subscription

Watch for changes under the prefix; the callback's value is nil when the key was deleted. Pass "" to match every write.

Example
local sub = doc:subscribe("players/", function(key, value)
    print(key, value) --> players/ada 3
end)
doc:set("players/ada", 3)

Document:grant

methodsuspends
Document:grant(opts?: documents.GrantOptions) -> DocumentGrant

Mint a grant from this handle's authority. With to, the grant is bound to that identity; without it, anyone holding the encoded string holds its authority. A write grant always carries read alongside. A network grant starts from this handle's own access, not from the part of the document the handle syncs: it reads the document's history and the changes stamped until it ends, and once it ends, DatumHue stops syncing the document to its holder. A network write grant adds changes stamped from an hour before it was made until it ends; a newer change to the same key wins. A grant cannot be withdrawn. Raises on any attempted widening, and on a handle opened from the last grant a line can hold. Network grants made each from the one before form a line that holds eight from a network document documents.create made and seven from a named or communal one; a grant past them could not sync.

Example
-- Without `to`, whoever holds the encoded string may read.
local grant = doc:grant({ mode = "read" })
print(grant.mode, grant.bearer) --> read true
local encoded = grant:encode()

opts documents.GrantOptions options 4 keys

KeyTypeDefaultDescription
tostringa bearer grant: anyone holding the encoded string holds its authorityReceiver identity key the grant is bound to.
mode"read" | "write""read"Never wider than the granting handle's own mode.
prefixstringthe granting handle's own subtreeNarrow the grant to this key subtree.
valid_daysinteger30 days; a local grant never expiresDays the grant lasts, counted from an hour before now. It never outlasts the granting handle's own access.

Document:close

methodsuspends
Document:close()

Close this handle. Other handles and subscriptions on the same document keep working. Once none is open on a network document, DatumHue stops syncing it on this workstation until it is opened again; what was written here before still reaches the workstations it was syncing with. An app's handles close when the app ends.

datumhue.com

(c) 2026 Shuusei AB. Quote excerpts of this manual, with attribution to DatumHue, in your own documentation, tutorials, course materials, reviews, and other writing or video. Republishing it in whole or in substantial part needs written permission: support@datumhue.com.

Victor Mono is licensed under the SIL Open Font License 1.1
Copyright (c) 2024, Rune Bjørnerås (https://github.com/rubjo)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Try

    ↑↓ selectEnter openTab filter

    Settings

    Theme
    Text
    Print

    Keyboard shortcuts

    / or Ctrl KSearch
    ↑ ↓ EnterPick a result
    TabNext result filter
    j kNext or previous entry
    [ ]Previous or next page
    yCopy a link to the current entry
    ?These shortcuts
    EscClose

    On this page