Skip to content

senecajs-labs/seneca-shard-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Seneca

A Seneca.js data storage plugin

seneca-shard-store

Build Status Gitter

Node.js seneca data storage module that uses multiple stores

This module is a plugin for the Seneca framework. It provides a storage engine that uses multiple stores, called shards. The data is divided equally at time of creation, using an id built by the sharder module.

Install

npm install seneca
npm install seneca-shard-store

Test

cd test
mocha shard.test.js --seneca.log.print

Quick example

This example uses two jsonfile-store.

var seneca = require('seneca')()
si.use(require('seneca-jsonfile-store'),{
  map: {
    'store1/-/-': '*'
  },
  folder: __dirname + '/db1'
})

si.use(require('seneca-jsonfile-store'),{
  map: {
    'store2/-/-': '*'
  },
  folder: __dirname + '/db2'
})

si.use(require('..'),{
  shards: {
    1: {
      zone: 'store1',
      append: true
    },
    2: {
      zone: 'store2',
      append: true
    }
  }
})

seneca.ready(function(){
  var apple = seneca.make$('fruit')
  apple.name  = 'Pink Lady'
  apple.price = 0.99
  apple.save$(function(err,apple){
    console.log( "apple.id = "+apple.id  )
  })
})

Usage

You don't use this module directly. It provides an underlying data storage engine for the Seneca entity API:

var entity = seneca.make$('typename')
entity.someproperty = "something"
entity.anotherproperty = 100

entity.save$( function(err,entity){ ... } )
entity.load$( {id: ...}, function(err,entity){ ... } )
entity.list$( {property: ...}, function(err,entity){ ... } )
entity.remove$( {id: ...}, function(err,entity){ ... } )

Support

If you're using this module, and need help, you can:

Contributing

The Senecajs org encourage open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.

Acknowledgements

This project was kindly sponsored by nearForm.

License

Copyright Matteo Collina and other contributors 2014-2016, Licensed under MIT.

Releases

No releases published

Packages

No packages published