Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ricki-bumbledev/bumbledb
Embedded, file-based database with MongoDB-like API for Node.js
https://github.com/ricki-bumbledev/bumbledb
Last synced: about 2 months ago
JSON representation
Embedded, file-based database with MongoDB-like API for Node.js
- Host: GitHub
- URL: https://github.com/ricki-bumbledev/bumbledb
- Owner: Ricki-BumbleDev
- License: mit
- Created: 2019-10-06T16:15:43.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-28T01:24:44.000Z (about 1 year ago)
- Last Synced: 2024-11-09T16:49:55.786Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/bumbledb
- Size: 189 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BumbleDB
Embedded, file-based database with MongoDB-like API for Node.js
## Getting started
```ts
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);
```## Insert data
### `insertOne`
```ts
const someDocument = { id: 1, name: 'Meredith', country: 'US' };
await db.collection('users').insertOne(someDocument);
```### `insertMany`
```ts
const someDocuments = [
{ id: 1, name: 'Meredith', country: 'US' },
{ id: 2, name: 'Monika', country: 'DE' }
];
await db.collection('users').insertMany(someDocuments);
```## Query data
### `findOne`
```ts
const result = await db.collection('users').findOne({ id: 5 });
```### `find`
Get all documents
```ts
const result = await db
.collection('users')
.find({})
.toArray();
```Get documents matching query
```ts
const result = await db
.collection('users')
.find({ name: 'Monika', country: 'DE' })
.toArray();
```Query using nested attributes
```ts
const result = await db
.collection('users')
.find({ 'address.country': 'DE' })
.toArray();
```## Update data
### `update`
```ts
const newDocument = { id: 1, name: 'users', country: 'US' };
await db.collection('users').update({ id: 1 }, newDocument);
```## Delete data
### `delete`
```ts
const affected = await db.collection('users').delete({ id: 1 });
```