npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

neutrinodb

v0.0.1

Published

A json document database built on node.js and leveldb

Downloads

5

Readme

NeutrinoDB

A json document database built on node.js and leveldb

This database is experimental, not for production use

Motivation

This is a learning exercise. I wanted to combine LevelDB (using the levelup module)
with express to provide an HTTP interface and odata-parser to provide a querying syntax.

Architecture

Neutrino is a web server, you read/write the data over http using either raw http requests, or the client library.

Install and start the Server

$ git clone https://github.com/richorama/neutrinodb.git
$ cd neutrinodb/database
$ [sudo] npm install
$ node server

Connect using the client

Install the neutrino package.

$ npm install neutrinodb

In your node application you can create a database client like this:

var client = require('neutrino')('http://localhost:8080/');

Create, list and delete tables

Neutrino has the concept of tables, you can create, list and delete them like this.

// create a new table called 'table1'
client.createTable('table1', function(err){
	if (err) console.log(err);
})

// list all tables in the database
client.tables(function(error, tables){
	if (err) console.log(err);
	tables.forEach(function(table){
		console.log(table);
	});
});

// delete 'table2' from the database. This will delete all data in the table
client.deleteTable('table2', function(err){
	if (err) console.log(err);
})

Create, get, list and delete objects

You can add, remove and list objects in your table like this:

// create an object withe the 'A' key 
client.put('test1', 'A', {foo:"bar"}, function(err){
	if (err) console.log(err);
});
	
// get object 'A' back
client.get('test1', 'A', function(err, data){
	if (err) console.log(err);
	console.log(data); 
});	

// delete object 'A'
client.del('test1', 'A', function(err){
	if (err) console.log(err);
});

// retrieve all records from table 1
client.query('table1', function(err, objects){
	objects.forEach(function(object){
		console.log(object);
	});
});

Querying tables

Tables can be queried using the OData syntax:

// all objects where foo = 'bar'.
client.query('table1', "foo eq 'bar'", function(err, data){ ... });

// first 5 objects matching the query
client.query('table1', "foo eq 'bar'", {top: 5}, function(err, data){ ... });

// second page of 5 objects matching the query
client.query('table1', "foo eq 'bar'", {top: 5, skip: 5}, function(err, data){ ... });

Note that querying a table like this will result in a full table scan.

If you only want one (or a few) records, use the 'top' option to improve performance.

Views

To avoid full table scans, you can register 'views' which will be indexed for you by the database.

client.registerView('view1', 'table1', "foo eq 'bar'", function(err){ ... });

client.queryView('view1', function(err, data){ ... });

Views can also be parameterised, on the condition that only one parameter is used, and that's used to test if a property is 'eq'.

client.registerView('view1', 'table1', "foo eq '?'", function(err){ ... });

client.queryView('view1', 'bar', function(err, data){ ... });
client.queryView('view1', 'baz', function(err, data){ ... });

At the moment views cannot be deleted.

License

MIT