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

@zoranmil/jsondb

v1.0.11

Published

An easy-to-use JSON database

Downloads

722

Readme

@zoranmil/jsondb

An easy-to-use JSON database which can be used for small data storage, up to 100mb without getting slow.

Portable Node.js database, very useful.

Features

Pros

  1. Portability
  2. Easy-to-use
  3. Can control several db’s at the same .js file
  4. Pretty fast when treating small volumes of data

Cons

  1. Slow when dealing with big data volumes
  2. Low security, just erase the .json created and the data is lost

Installing

Just run:

npm i @zoranmil/jsondb

Then, in your .js, summon it with:

const DB = require('@zoranmil/jsondb')

and you're ready to go!

How to use

Always when treating strings on function arguments, go with ‘stringName’ instead of stringName. While when treating with ints, Boolean, etc just go without ‘ ‘.

Creating a database

Just run:

const DBNAME="dbname";
const DB=new Db( DBNAME,{ dir:"./"});

dbname is the name of your database, and it will create the dbname.json.

in windows you don't have to take the directory just call

const DB=new Db( DBNAME);

the json will be in

ProgramData directory

Inserting data

Just run:

Insert(json,primry_key);

let json={'name':name,"price":price,"amount":amount,"brand":brand}; primry_key='id';

DB.Insert(json,primry_key);

Searching for data

Select All:

let dbdata=DB.Select().get();

Selects all data from database.

Select Limit:

Limit(from,records_per_page)

let dbdata=DB.Select().Limit(from,records_per_page).get();

Sorting:

    ByIdDesc(key);
    ByIdAsc(key);
    ByNameAsc(key);
    ByNameDesc(key)

let dbdata=DB.Select().ByIdDesc('id').get();

let dbdata=DB.Select().Limit(from,records_per_page).ByNameDesc('name').get();

Select Where :

  Where(key,value);

let data= DB.Select().Where(key,value).get();

It selects all data which satisfies condition key > value.

Select Between

Between ( key, value1, value2);

DB.Select().Between ( 'price' ,100,200).get();

Select Like

  Like (key,name)

DB.Select().Like( 'name' ,'zora').get();

Insert:

Insert(json,primry_key);

let json={'name':name,"price":price,"amount":amount,"brand":brand};

primry_key='id';

DB.Insert(json,primry_key);

Update:

Update(json,  key,value);

let json={'name':name,"price":price,"amount":amount,"brand":brand};

key='id';

where_value=1;

DB.Update(json, key,where_value);

Delete:

Delete(key,value);

key='id';

where_value=1;

DB.Delete( key,where_value);