seneca-shard-store

Sharding for Seneca

seneca-shard-store

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.

If you're using this module, feel free to contact me on twitter if you have any questions! :) @matteocollina

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  )
  })
})
npm install seneca
npm install seneca-shard-store

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){ ... } )
cd test
mocha shard.test.js --seneca.log.print

This project was kindly sponsored by nearForm.

MIT