Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gun-mongo-key

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gun-mongo-key

A Mongo key:value adapter for Gunjs

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Gun-Mongo

A key:value MongoDB adapter for GunJS.

Some Considerations

gun-mongo-key stores the each graph node's key:value (along with some metadata) in a separate document. This provides some major advantages in two areas: streaming large nodes (so that memory isn't overwhelmed) and making updates faster. The disadvantage is that creating new nodes (especially) nodes with lots of properties will be less efficient.

If the following are true, then gun-mongo-key could be right for your application:

  1. You anticipate large nodes (e.g., a users node with millions of children will be streamed to Gun rather than transferred in the entirety).
  2. Nodes or node properties are updated frequently. Updates (especially of large nodes) of individual properties will be faster and more efficient than full-node storage.
  3. Updating existing nodes is more common/important than creating new nodes.

Contrast this with gun-mongo which has an advantages for creating nodes. This advantage dwindles at the point where a node becomes so large that it threatens to overwhelm memory.

Installation

yarn add gun-mongo-key or npm install gun-mongo-key.


const Gun = require('gun');

// Must be added after Gun but before instantiating Gun
require('gun-mongo-key');

// Instantiate Gun
const gun = new Gun({
    file: false,
    web: httpServer,

    // The following are defaults. You can supply `true` to use all defaults
    mongo: {
        host: 'localhost',
        port: '27017',
        database: 'gun',
        collection: 'gun_mongo_key',
        query: ''
    }
});

Performance

Tests run on a 2012 Macbook Pro, 2.5 GHz Intel Core i5, 16 GB RAM.

Starting with empty collection:

  • Write 10000 nodes: : 11579ms; 11.579s; 1.1579 ms/node.
  • Read 10000 nodes: : 18681ms; 18.681s; 1.8681 ms/node.
  • Update 10000 nodes: : 12798ms; 12.798s; 1.2798 ms/node.

1.2 million existing documents in the collection:

  • Write 10,000 nodes: : 11,858ms; 11.858s; 1.1858 ms/node.
  • Read 10,000 nodes: : 26,289ms; 26.289s; 2.6289 ms/node.
  • Update 10,000 nodes: : 12,308ms; 12.308s; 1.2308 ms/node.

Issues & Contributing

Issues welcome on Github.

Community contributions welcome. PRs accepted after code review.

Keywords

FAQs

Package last updated on 14 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc