Socket
Book a DemoInstallSign in
Socket

ripdb

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ripdb

JavaScript embeddable JSON time series database.

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

RipDB

build status windows build status npm js-standard-style

A 100% JavaScript embeddable JSON time series database.

API is unstable.

Name

The name "Rip" in RipDB is from Rip Van Winkle.

Why?

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.

Design Goals

  • No native modules, 100% embeddable.
  • Super simple file format. Indexed (typically by day) newline delimited JSON (.ndjson) with two top level fields d, and t.
  • Simple interface. Node.js streams only to read or write.

Caveat Emptor

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.

Usage

Install

npm i --save ripdb

API

create()

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')

prototype.path

prototype.createReader()

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.

prototype.createWriter()

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.

License

MIT

Copyright (c) JP Richardson

Keywords

time

FAQs

Package last updated on 26 Dec 2015

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