insert

abstract suspend fun insert(source: InputStream, types: Map<String, String> = emptyMap()): DocId(source)

Inserts the JSON document read from source, which isn't closed; returns its docId once it's visible. Cancelling the call stops it at the next read of source, and nothing of the document becomes visible; once source is read to its end, the insert completes and returns even if the call is cancelled (SPEC.md §8).

types maps JSON paths to type names, assigned atomically with the insert. A path is an RFC 9535 singular query without negative indexes (SPEC.md §6.1), such as $.order.items[0] or $['@type']. An invalid path throws InvalidJsonPathException and an invalid name InvalidTypeNameException before anything is read; a path that selects nothing, or a value that isn't an object, rejects the document with RejectReason.TYPE_PATH_UNMATCHED.

In a store with a CreationOptions.documentKey, a document without a key is rejected with RejectReason.KEY_MISSING, and one whose key a visible document already has throws WriteConflictException with WriteConflictException.key set; upsert replaces that document instead.


abstract suspend fun insert(path: Path, types: Map<String, String> = emptyMap()): DocId(source)

Inserts the document in the file path, read as it is split; the file is opened and closed by the call.


abstract suspend fun insert(json: String, types: Map<String, String> = emptyMap()): DocId(source)

Inserts a document given as a string; meant for small documents.