replace

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

Inserts the JSON document read from source as insert does, and deletes the documents of docIds in the same atomic change (SPEC.md §7.1): once it's acknowledged the new document is visible and they are deleted, and a crash leaves either both or neither. Returns the new document's docId.

It is a compare-and-set: every document of docIds must still be visible when the change takes effect. When one isn't — deleted, replaced by another call first, or never stored — it throws WriteConflictException and changes nothing; a conflict known when the call starts throws before source is read. Repeated docIds count once, and with none it is an insert.


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

replace with the document in the file path, opened and closed by the call.


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

replace with the document given as a string; meant for small documents.