low-json-db

API Reference

JSONDB

MethodDescription
new JSONDB(path)Create / open a database
collection(name|options)Get or create a collection
listCollections()List all collection names
dropCollection(name)Delete a collection
unloadCollection(name)Remove collection from memory
backup(path?)Create a full backup
backupAsync(path?)Async backup

Collection

MethodDescription
insert(doc) / insertAsyncInsert one document
insertMany(docs) / insertManyAsyncInsert multiple documents
find(query?)Start a query (returns QueryBuilder)
findOne(query?) / findOneAsyncFind first matching document
updateOne(filter, update) / updateOneAsyncUpdate first match
updateMany(filter, update) / updateManyAsyncUpdate all matches
deleteOne(filter) / deleteOneAsyncDelete first match
deleteMany(filter) / deleteManyAsyncDelete all matches
import(file, options?) / importAsyncImport documents
startTransaction()Begin a transaction
aggregate(pipeline)Run aggregation pipeline
rebuildId() / rebuildIdAsyncRecalculate next auto ID

QueryBuilder

MethodDescription
limit(n)Limit results
skip(n)Skip results
sort(obj)Sort results
project(obj)Select fields
toArray()Execute and return array
first()Return first document
count()Return count
Next: See practical Examples.