Document Functions
These functions either create new documents or modify existing ones.
.check(id)
Checks if the given document exists or not. Returns a Boolean value.
.size()
Returns the size of the current, or target, directory that is currently in use.
.delete(id)
Deletes the specified document permanently.
.insert(Object)
Creates a new document in the default or given directory. Unless serialization is enabled, ensure an "id" key is provided.
.insertBulk([ Objects ])
Creates a new document containing multiple objects. An "id" key is required to create a bulk document as serialization is not supported.
.update({id, key, child, change, math?})
Updates a key and/or child key within the given document. The "math" parameter, which defaults to false, only supports simple math such as addition or subtraction
.mupdate(id, [ Objects ])
Updates multiple keys within the given document. The Objects contained within the Array follow the same format as .update(), excluding the "id" parameter.
.append({ id, key, value, position })
Appends a new key and value to an object within a bulk document. Provide a "position", an integer corresponding to which object in the array, to append the new key and value to that specific object.
.replicate(id, {to, from, force?})
Copies a document from the directory specified in the "from" argument. The suffix "_rep" is added to the document name if the file already exists and "force" is set to true.
.set(id, {data})
Overwrite the specified document with new data. The previous data will be stored in a cache as long as the process is still running and the function doesn't overwrite another document.
Everything is overwritten. This includes the "id" key in the target document. Don't specify one unless you absolutely need to.
.undo()
Undo the most recent changes made to a document with .set() using the data stored in the cache.
Last updated