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

node-jsdb

v1.0.1

Published

Shared-object database w/jPath, locking, subscriptions

Downloads

10

Readme

node-jsondb

JSON shared object database


Description

node-jsondb is a shared object database which can traverse an object structure, read properties, change properties, and handle record locks (transactions) and subscriptions.

When used in conjunction with node-jsondb-srv, it acts as a database server which accepts socket connections via node-jsondb-client.

Installation

npm install node-jsdb

or

git clone https://github.com/mcmlxxix/node-jsondb.git

you can also add https://github.com/mcmlxxix/node-jsondb.git as a dependency to your project's package.json file

NOTE: to use the full socket service, which already has this library as a dependent, see node-jsondb-srv and/or node-jsondb-client for installation instructions.

Features

jPath queries:

path/to/object[property==value]
path/object
path/to/object[property > 0 && property < 10]
path/to/array(index)
etc..

Transactions:

with transaction mode enabled for a given database, any changes to the database must be preceded by a "write lock" on the affected records, and any locks or writes that fail during the transaction will cause the transaction to fail entirely, and the data will remain unchanged.

Database locks:

with "full" lock mode enabled, any changes to the database must be preceded by a "write lock," and no changes will be allowed anywhere in the database until it is unlocked.

No locks:

you can also throw caution to the wind, be a wild and crazy guy, and just let any client make any changes they want without locking. This is most useful in chat room databases and other applications where you are more interested in distributing subscription updates than maintaining data integrity.

Subscriptions:

clients may "subscribe" to a particular record location, and those clients will receive a packet containing the latest copy of the data stored at that location (or it will be passed to a callback) any time another client makes a change affecting that record.

Save/Load:

databases can be saved to file (in JSON format) and loaded from file (in JSON format)

Packet Structure

request={
	id: <client id>,
	db: <database name>,
	oper: <database operation>,
	data: <see below>
};

oper = READ
	data = [
		{ path:"path/to/data" },
		...
	];

oper = WRITE
	data = [
		{ path:"path/to/data", key:"child_property", value:"value_to_be_written" },
		...
	];

oper = UN/LOCK
	data = [
		{ path:	"path/to/data", lock: <see lock types> },
		...
	];
	
oper = UN/SUBSCRIBE
	data = [
		{ path:	"path/to/data" },
		...
	];
	
LOCK TYPES
	read = "r"
	write = "w"
	append = "a"
	

Methods

db.load(fileName); 
db.save(fileName);

db.read(request,callback);
db.write(request,callback);

db.lock(request,callback);
db.unlock(request,callback);

db.subscribe(request,callback);
db.unsubscribe(request,callback);

Properties

db.settings.locking = "transaction" | "full" | null
db.settings.maxconnections = num