A MongoDB adapter for GunJS.
gun-mongo
stores the each graph node (along with some metadata) in a document and uses the key as the Mongo '_id'. This makes gun-mongo
right for some application but not all.
If the following are true, then gun-mongo
could be right for you:
users
node with millions of children would be problematic). Most nodes are small to medium. Fair warning: If a node grows too large, it could overwhelm memory and cause crashes.Contrast this with gun-mongo-key
. Whereas gun-mongo-key
has the advantage for updates and enabling streaming of large nodes, gun-mongo
makes Node creation much more efficient.
yarn add gun-mongo
or npm install gun-mongo
.
const Gun = require('gun');
// Must be added after Gun but before instantiating Gun
require('gun-mongo');
// Instantiate Gun
const gun = new Gun({
file: false,
web: httpServer,
// The following are defaults. You can supply `true` to use all defaults, or overwrite the ones you choose
mongo: {
host: 'localhost',
port: '27017',
database: 'gun',
collection: 'gun-mongo',
query: ''
}
});
Tests run on a 2012 Macbook Pro, 2.5 GHz Intel Core i5, 16 GB RAM.
Small Nodes: 10 Properties Each
Medium Nodes: 1000 Properties Each
Issues welcome on Github.
Community contributions welcome. PRs accepted after code review.
Version | Tag | Published |
---|---|---|
0.1.2 | latest | 5yrs ago |