1.0.6 • Published 7 years ago

turtlesoup v1.0.6

Weekly downloads
13
License
MIT
Repository
github
Last release
7 years ago

turtlesoup

Minimal Event Sourcing helper for RethinkDB & node.js

Build Status

install

npm install turtlesoup --save

usage

/*
// first create a db and table
var r = require('rethinkdb');
r.connect(function (err, conn) {
	r.create('demo').tableCreate('bucket').run(conn, function (){});
});
*/
var _turtlesoup = require('turtlesoup');
var turtlesoup = new _turtlesoup('demo', 'bucket'

setInterval(function () {

	turtlesoup.add({ demo: Math.random() * 11, timestamp: new Date() });

}, 1000);

pull(
	turtlesoup.get_all_latest(),
	pull.log()
)

methods

add

turtlesoup.add({ demo: true, timestamp: new Date().toISOString() });

Add a new JSON object with mandatory timestamp field which needs to be a Javascript Date object.

get_all

turtlesoup.get_all(function (results) {
	console.log(results);
});

// or

turtlesoup.get_latest(function({ demo: true }, function (results) {
        console.log(results, 'filtered on demo property');
});

Returns an array of all items in the table.

get_all_latest

turtlesoup.get_all_latest(function (results) {
        console.log(results);
});

// or

turtlesoup.get_all_latest(function({ demo: true }, function (results) {
	console.log(results, 'filtered on demo property');
});

Returns an array of all the items in the table with the latest first.

pull_all

pull(
	turtlesoup.pull_all(),
	pull.log()
)

// or

	turtlesoup.pull_all({ demo: true }) // filter on demo === true

Get each data item from a pull stream source.

pull_all_latest

pull(
	turtlesoup.pull_all_latest(),
	pull.log()
)

//

	turtlesoup.pull_all_latest({ demo: true }) // filter on demo === true

Get each item from a pull stream source with the latest coming first.

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago