A 100% JavaScript embeddable JSON time series database.
API is unstable.
The name "Rip" in RipDB is from Rip Van Winkle.
Often times it's useful to have data indexed by date/time. Examples of such data would be log data, stock data, etc. There are plenty of time series databases, however, none that I'm aware of that are embeddable.
RipDB is useful if you're building an Electron app and you don't want to recompile LevelUp for every target platform.
- No native modules, 100% embeddable.
- Super simple file format. Indexed (typically by day) newline delimited JSON (
.ndjson
) with two top level fieldsd
, andt
. - Simple interface. Node.js streams only to read or write.
I don't maintain that this is a good idea, nor is even fast/efficient. This should be thought of as more of an experiment. If your data set is larger than 100 MB, you may be better served by another embeddable database or time series database.
npm i --save ripdb
create(path, [indexFn])
Parameters:
path
: The path directory to read / write a RipDB database.indexFn
: Optional function to use for indexing. Defaults to returning a path that indexes like${path}/YYYY/mm-dd.ndjson
. Files should easily fit in memory.
Returns: An instance of RipDB.
var ripdb = require('ripdb')
var db = ripdb.create('~/data/stocks')
Returns an instance of Readable stream used to read data from the database. Starts from the most recent.
var ripdb = require('ripdb')
var db = ripdb.create('~/data/stocks')
var reader = db.createReader()
reader.on('readable', function () {
var record = reader.read()
console.dir(record)
// => { index: '2015/12-05', t: '2015-12-05T10:36:56-06:00', d: data... }
})
Will support middleware, JSON revivers, etc.
Returns an instance of a Writable stream used to write data.
var ripdb = require('ripdb')
var db = ripdb.create('~/data/stocks')
var writer = db.createWriter()
writer.write({
t: new Date() // expected to be instance of Date
d: { ...data } // your data
})
Will support middleware, JSON replacers, etc.
MIT
Copyright (c) JP Richardson