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

local-storage-db

v1.0.0

Published

A minimal NoSql data storage for web application using browser LocalStorage API

Downloads

48

Readme

Coverage Status Build Status Code Climate

LocalStorageDB

LocalStorageDB is an enhancement of the built-in localStorage for browsers, it gives you the ability to save complex data localy for rapid application development.

It works like Firebase except less complex and this time it's offline. It's useful in instances where you want to cache little or large data within the application on the user's machine.

why use LocalStorageDB?

  • It's pretty fast and lightweight (2kb)
  • It has the least complex data storage api while also providing rich functionality
  • No form of setups required

Installation

To get the latest version of LocalStorageDB, simply run this command

via npm

 npm install local-storage-db

via bower

bower install local-storage-db

Alternatively you can download it from github as a zip, extract and move it to your project directory

you will then need to link it like this

<script type="text/javascript" src="LocalStorageDB/dist/localStorageDB.min.js">

Usage

// For node only

import LocalStorageDB from 'local-storage-db';

First create an instance to use for your app. The construtor parameter is similar to the key in the setItem method and is required.

NOTE: you can create multiple instance for your app if you want

Creating data

const db = new LocalStorageDB('documents');

// CREATING DATA

db.create('users', [{id: 1, name: 'john-doe'}, {id: 2, name: 'jane-doe'}]);
// append new user
db.create('users', {id: 3, name: 'dan-daniels'});

// this would return
// {"users" : [ {id: 1, name: 'john-doe'}, {id: 2, name: 'jane-doe'}, {id: 3, name: 'dan-daniels'}]}

// similarly you can create new data like this

db.create('pictures', { img: 'pic1.jpg', ownerId: 1 } );
db.create('pictures', { img: 'pic2.jpg', ownerId: 2 } );

// this would return
// { pictures: [{ img: 'pic1.jpg', ownerId: 1 }, { img: 'pic2.jpg', ownerId: 2 }] }

Reading data



db.get();

/* this would return
{ "users" : [ {id: 1, name: 'john-doe'}, {id: 2, name: 'jane-doe'}, {id: 3,
name: 'dan-daniels'}],
  "pictures": [{ img: 'pic1.jpg', ownerId: 1 }, { img: 'pic2.jpg', ownerId: 2 }]
}
*/

db.get('pictures');
//this would return

/*
[{ img: 'pic1.jpg', ownerId: 1 }, { img: 'pic2.jpg', ownerId: 2 }]
*/

db.get('users', 2);

// this would return
// {id: 3, name: 'dan-daniels'}

Updating data

db.update( {id: 3, name: 'Dr Dan Daniels'}, 'users' , 2);

// this would override the third user with new information resulting to:
/*
{"users" : [ {id: 1, name: 'john-doe'}, {id: 2, name: 'jane-doe'}, {id: 3,
name: 'Dr Dan Daniels'}]}
*/

db.update( [], 'pictures')
// this would override the pictures saved already with an empty array

Deleting data

db.remove('pictures');

// this would remove the picture key from the object

db.remove('users', 0);
// this would remove the first element in the users array
/*
"users" : [{id: 2, name: 'jane-doe'}, {id: 3, name: 'dan-daniels'}]
*/

db.remove();
// this would remove every item in the object

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

License

The MIT License (MIT). Please see License File for more information.