A key:value TingoDB adapter for GunJS.
gun-tingo
stores the each graph node's key:value (along with some metadata) in a separate document.
TingoDB is an embedded JavaScript in-process filesystem or in-memory database upwards compatible with MongoDB at the API level.
PROOF OF CONCEPT. DO NOT USE THIS.
This Gun hack is made possible by the awesome work of Mark Nadal, Spencer Jones and the GunDB community. For anything serious, please refer to gun-mongo
and gun-mongo-key
adapters.
yarn add gun-tingo
or npm install gun-tingo
.
const Gun = require('gun');
// Must be added after Gun but before instantiating Gun
require('gun-tingo');
// Instantiate Gun
const gun = new Gun({
file: false,
web: httpServer,
// The following are defaults. You can supply `true` to use all defaults
mongo: {
database: 'gun',
collection: 'gun_mongo_key',
query: '',
opt: {
poolSize: 25 // how large is the connection pool
// include any other options when initializing:
// See: http://mongodb.github.io/node-mongodb-native/2.2/reference/connecting/connection-settings/
},
chunkSize: 250 // see below
}
});
For optimal performance, GunMongoKey will chunk key:value results into groups of 250 to stream back to Gun. The default is set fairly high at 250. If you anticipate that nodes might contain large values (e.g., 250 key:value pairs might overwhelm the memory), then you may want to set this lower. If all of the values are small (even if the node itself has many keys), consider setting this higher.
Issues welcome on Github.
Community contributions welcome. PRs accepted after code review.