- Notifications
You must be signed in to change notification settings - Fork0
A lightweight BSON-based, document-oriented database for Javascript — built for speed, simplicity, and happiness.
License
grinwiz/bisondb
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A lightweight BSON-based, document-oriented database for Javascript — built for speed, simplicity, and happiness.
BisonDB is a lightweight, BSON-based, document-oriented database designed to run seamlessly in Node.js, Electron, and the browser. It stores data in a compact binary format ([len][bson]…) and supports a familiar MongoDB-like API —insertOne,find,updateOne,aggregate, and more — without any build step or external dependencies beyondbson.
| Feature | Benefit |
|---|---|
| Zero config | new BisonDB() works instantly |
| File-based (Node.js) | Auto-saves to.bisondb/ |
| IndexedDB (Browser) | Full offline support |
| Streaming engine | O(1) memory, no full loads |
| MongoDB-like API | insertOne,find,update,aggregate |
| Transactions | ACID guarantees |
| No build step | Pure JS, no TypeScript |
Whether you need an embedded datastore for a server, a desktop app, or a client-side web app, BisonDB delivers speed, simplicity, and reliability in a single pure-JavaScript package.
Module name on npm isbisondb.
npm install --save bisondb
constdb=newBisonDB();
| Method | Description |
|---|---|
collection(name) | Returns aCollection instance |
transaction(collections, fn) | ACID transaction |
constusers=db.collection("users");
| Method | Returns | Example |
|---|---|---|
insertOne(doc, { returnDocument }) | doc or{ _id } | returnDocument: 'after' |
insertMany(docs) | [_id] | |
find(query, { projection }) | doc[] | { name: 1 } |
findOne(query, { projection }) | doc | null | |
updateOne(filter, update, options) | result | $set: { x: 1 } |
update(filter, update, options) | { acknowledged, matchedCount, modifiedCount } | $set: { x: 1 } |
deleteOne(filter) | { deletedCount } | |
delete(filter) | { deletedCount } | |
aggregate(pipeline) | any[] | $match,$group |
const{ BisonDB}=require("bisondb");constdb=newBisonDB();awaitdb.collection("users").insertOne({name:"Alice"});console.log(awaitdb.collection("users").find());
Saves to
.bisondb/users.bsonin your project root.
import{BisonDB}from"bisondb/client";constdb=newBisonDB();awaitdb.collection("todos").insertOne({task:"Learn BisonDB"});
UsesIndexedDB — full offline persistence.
const{ BisonDB}=require("bisondb");(async()=>{console.log("BisonDB Usage Demo\n");// 1. Initialize DBconstdb=newBisonDB();constusers=db.collection("users");constposts=db.collection("posts");console.log("1. Collections created: users, posts");// 2. insertOne + returnDocument: 'after'constalice=awaitusers.insertOne({name:"Alice",email:"alice@example.com",role:"admin"},{returnDocument:"after"});console.log("2. insertOne (returnDocument:after):",alice);// 3. findById (using _id from insert)constfoundUser=awaitusers.findOne({_id:alice._id});console.log("3. findById:",foundUser);// 4. insertManyconstnewUsers=[{name:"Bob",email:"bob@example.com",role:"user"},{name:"Charlie",email:"charlie@example.com",role:"moderator"},];constinserted=awaitusers.insertMany(newUsers);console.log("4. insertMany result:",inserted);// Returns array of _id strings// 5. insert a postconstpost=awaitposts.insertOne({title:"First Post",authorId:alice._id,content:"Hello BisonDB!"},{returnDocument:"after"});console.log("5. Post inserted:",post);// 6. updateOne with returnDocument: 'after'constupdatedUser=awaitusers.updateOne({_id:"690355f49c12ad51e1721bad"},{$set:{lastLogin:newDate(),status:"online"}},{returnDocument:"after"});console.log("6. updateOne (returnDocument:after):",updatedUser);// 7. updateManyconstupdatedUsers=awaitusers.update({},{$set:{status:"offline"}});console.log("7. updateMany:",updatedUsers);// 8. findOneconstuserByEmail=awaitusers.findOne({email:"bob@example.com"});console.log("8. findOne by email:",userByEmail);// 9. deleteOneconstdeleteResult=awaitusers.deleteOne({email:"charlie@example.com"});console.log("9. deleteOne result:",deleteResult);// 10. deleteManyconstdeleteManyResult=awaitusers.delete({email:"bob@example.com"});console.log("9. deleteOne result:",deleteManyResult);// 10. findOne with projection (name only)constnameOnly=awaitusers.findOne({email:"alice@example.com"},{projection:{name:1}});console.log("10. findOne with projection { name: 1 }:",nameOnly);// Bonus: Aggregation exampleconststats=awaitusers.aggregate([{$match:{role:{$ne:"admin"}}},{$group:{_id:"$role",count:{$sum:1}}},]);console.log("\nBonus: Aggregation $group by role:",stats);console.log("\nAll operations completed successfully!");})();
| Dataset | NeDB (Est.) | BisonDB |
|---|---|---|
| 10k docs | ~80ms load | Streaming: <10ms |
| 100k docs | OOM risk | Stable, low RAM |
BisonDB useszero-copy streaming — never loads full file.
Contributions, issues, and feature requests are welcome!Feel free to open an issue or submit a pull request on GitHub.
- Fork the repository
- Create a new branch
git checkout -b feature/my-new-feature
- Commit your changes
git commit -m"feat(my-new-feature): Add my new feature" - Push to your branch
git push origin feature/my-new-feature
- Open a Pull Request 🚀
Liked BisonDB? Give it a star on GitHub to show your support!https://github.com/grinwiz/bisondb
MIT — free for commercial & open-source use.
About
A lightweight BSON-based, document-oriented database for Javascript — built for speed, simplicity, and happiness.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
