Embedded, file-based database with MongoDB-like API for Node.js
import initializeDb from 'bumbledb';
const dataDirectory = process.env.DATA_DIRECTORY ?? '.data';
const db = await initializeDb(dataDirectory);
const someDocument = { id: 1, name: 'Meredith', country: 'US' };
await db.collection('users').insertOne(someDocument);
const result = await db.collection('users').find({}).toArray();
console.log(result);
const someDocument = { id: 1, name: 'Meredith', country: 'US' };
await db.collection('users').insertOne(someDocument);
const someDocuments = [
{ id: 1, name: 'Meredith', country: 'US' },
{ id: 2, name: 'Monika', country: 'DE' }
];
await db.collection('users').insertMany(someDocuments);
const result = await db.collection('users').findOne({ id: 5 });
Get all documents
const result = await db
.collection('users')
.find({})
.toArray();
Get documents matching query
const result = await db
.collection('users')
.find({ name: 'Monika', country: 'DE' })
.toArray();
Query using nested attributes
const result = await db
.collection('users')
.find({ 'address.country': 'DE' })
.toArray();
const newDocument = { id: 1, name: 'users', country: 'US' };
await db.collection('users').update({ id: 1 }, newDocument);
const affected = await db.collection('users').delete({ id: 1 });