oblivion-db
A local, file-based noSQL database.
Setup
Install: npm i oblivion-db
const OblivionDB = ; // Async IIFEasync { const db = await OblivionDB; };
Creating documents:
Specify the collection and data
const createOperation = await db; if !createOperationsuccess // If success is false, an error property will exist. throw createOperationerror; else // the operation succeeded so we should have a document: const user = createOperationdocument; // the Document's data property should hold all the raw data: console; // { name: "Raghav Misra", username: "raghavm" }
Finding a document:
Query the DB is not an async operation because a copy of the collection is stored in memory.
Find using a query
const findOperation = db; if !findOperationsuccess // If success is false, an error property will exist. throw createOperationerror; else // the operation succeeded so we should have a document: const user = createOperationdocument; // the Document's data property should hold all the raw data: console; // { name: "Raghav Misra", username: "raghavm" }
Find by id (returns the same thing as db.find
)
const _id = ; const findByIdOperation = db;