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

path-db

v1.0.5

Published

NodeJS local database module.

Downloads

15

Readme

Path DB


NodeJS local database module.

enter image description here

What is Path DB?

A database server without the actual server. Path DB runs with your nodejs app : Starts when your app starts and stops when your app is closed. Path DB relies heavily on current Unix/Dos norms to enable its functionality without an actual process. Path DB is also shipped with cement, a cli tool used to generate object schemas a.k.a bricks.

What is a brick?

A brick is your usual javascript object schema.

Nav

  1. Install
  2. Setup
  3. Searching
  4. Cement cli
  1. Bricks

Install


npm install path-db

With cement cli tool :

npm install -g path-db

Setup


Add this module to your NodeJS server/program.

var path = require("path-db");

Path 101


Save path

path.Save("entry/1/string", "string"); path.Save("entry/1/int", 10); path.Save("entry/1/object", {object:"example"});

Get path

path.Get("entry/1/object", function(data){ if(data){ console.log(data); } });

Delete path

path.Delete("entry/1/string");

Searching


Here is a set of helper functions to help you look through your path-db collections.

Look

Lookup a path. If one result is found an object will be returned instead of an array.

Example :

path.Look("data/bricks",{property-to-find : 'value'},function(data){
/* Data is object or array */ } );

You may also use Lookf to use a function instead of an object to query with.

Example :

Declaration of function :

function compare(brick){ if(brick[property-to-find] > 29) return true; return false; }

Execution :

path.Look("data/bricks",compare,function(data){
/* Data is object or array */ } );

Collection

Return all of the paths on a given collection.

Example :

path.Collection("data/bricks",function(data){ console.log(data); });

sortKey

Sort array in ascending order with specified property-name to use during classification.

Example :

path.Look("data/bricks",{},function(data){ console.log(data.sortKey("created")); } );

Limit

Limit the size of your array.

Example :

path.Look("data/bricks",{},function(data){ console.log(data.limit(2)); // limit to 2 } );

Skip

Skip entries by the specified int, therefore resizing your array,

path.Look("data/bricks",{},function(data){ console.log(data.skip(2)); // start at index 2 } );

Cement


Cement is a cli tool that creates models.

Commands

Create Brick

Simply run, the module will guide the rest.

$ cement

Edit Brick

$ cement edit <brick name>

Set types

Please refer to https://www.npmjs.com/package/validate-fields#other-types for possible types.

$ cement val <brick name>

Delete Brick

$ cement del <brick name>

Bricks

Here is how path-db makes your cement models available to your NodeJS app.

Initialize a brick

var brick = path.<Brick name>(property-1, property-2...);

Your brick will have two extra properties : id : Unique item id. created : Date object of when this object was created.

Validate a brick

** It is crucial to add the v prefix prior to your Brick name.

console.log(path.v<Brick name>(brick));

This function will return a boolean based on validation success.