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

nebuladb

v1.1.0

Published

NebulaDB Graph Database

Downloads

8

Readme

NebulaDB

NebulaDB started out as a logic programming language but I decided to make it into a database because it would be my first, and there seemed to be many limitations of a graph based logic programming language. I am currently migrating the code base from using a compiled c data storage format, which was very slow, to using text-based storage, so some features may be missing in the interim.

NebulaDB runs on a Node server. There is a Node.js module for interfacing with the NebulaDB server that can be found here. To run this database, clone the repository or download from npm:

npm install nebuladb

Then run the server:

node nebula.js

You will see a little message telling you that the server is listening for requests, and then you can use the node_nebula module to save and query data.

Documentation

NebulaDB uses a simple graph based schema that looks like this:

[ source, relation, target ]

Entering three strings in this way creates three nodes in the database and sets up a special (Node)-[Link]-(Node) relationship between them. You can also use the reserved symbol '->' in the relation position to indicate that the source node has the state indicated by the target node, for example:

'john -> admin'
'john -> user'
'john first_name John'

This symbol '->' denotes a simple state. It is used for boolean properties, in other words properties that a node either has or does not have.

db.save("John -> admin");
db.save("Mary -> user");
db.query("Mary -> admin"); // returns false

There are two ways to query the database. The first way is to simply query a pattern. The database will response with a boolean that tell you whether or not the pattern exists in the database.

'john -> admin' //=> true
'john -> founder' //=> false

The second way to query is by using an asterisk to indicate which kinds of data you want to see. So far there are three available patterns:

db.query('john -> *')
// returns array of simple states: { simpleStates: ['admin','user'] }
db.query('john first_name *')
// returns the target pointed to by the node in the relation position: { first_name: ["John"] }
db.query('john * *')
// returns hash of all target states: { first_name: ['John'], hasState: ['admin'] }
db.query('* -> admin')
// returns array of all states that obtain the admin state: { simpleStates: ['john'] }
db.query('* * 30')
// returns hash of all source states: { 'age': ['john'], 'simpleState': ['old'] }

Initialization

db.init({name: "dbname"})

This method creates a new database with the name "dbname" and returns a nebuladb instance. If this is the first init, a json file will be created in the data directory, otherwise nebula will try to load previously saved data for this database. This method is not used directly, but is accessed via the node_nebula module's open method.

Saving

db.save('a b c')
db.saveAll(['a b c',
	    	'a b c',
	    	'a b c'
	   		])

The save method saves a record to the database. All non-existent nodes will be created. The saveAll method takes an array of records and pushes them all into the queue. Queries in string form will be parsed into arrays for processing, but if any of the terms contains spaces you can use array format to define the divisions between source, relation and target.

db.save('Dave -> user');
db.save(['Dave', 'comment', 'This board is too negative!']);

Querying

db.query('a b c', callback)

The query method tests the database using the given query and passes the result into the callack. There are currently eight types of queries:

[a,  b, c] // does item a have relation b to item c -> boolean
[a, ->, c] // does item a have state c -> boolean
[a, ->, *] // what are the states of item a -> array
[a,  b, *] // what is the item with relation b to item a -> object
[a,  *, *] // what are all the relation/target pairs for item a -> object
[*,  *, c] // what are all the source/relation pairs for item c
[*, ->, c] // what are all the states that obtain state c
[*,  b, c] // what item(s) have relation b to c