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

jsondb.ez

v0.0.3

Published

Simple database which stores data in JSON files!

Downloads

9

Readme

JsonDb.Ez

A simple package which uses JSON as a database to store values using keys in the form of

{"key": "key", "value": "value"}

This package was actually made to gather data and convert it into JSON but now you can use this as Data to JSON Convertor or as a simple Database. You just need right knowledge to use it!

Quick Example

Setting up database

const options = {
  filename: 'kek',
  clearOnStart: false
}

// options.filename will name the file as kek.json or else the default will be jsondb.ez
// options.clearOnStart will clear the data each and every time when it restarts file. The default will be false...

const { Database } = require('jsondb.ez')
const db = new Database(options)

Quick Example

db.set('foo', 'bar') // Will set value 'bar' for the key 'foo'

db.get('foo') // Will return 'bar'

db.all() // Will return all data in json format...

db.import(db.all()) // Will Import JSON data which is of jsondb.ez

db.startsWith('fo') // Will return all data starts with 'fo' in json format...

db.set('foo', 0)
db.add('foo', 1) // Will add data to the key 'key'
db.subtract('foo', 1) // Will subtract data to the key 'key'

db.delete('foo') // Will delete 'key' value...

db.push('foo', 'bar') // Will push the string to the array only if there is no value or an array value for that key!

db.deleteAll() // Will delete all data in json file...

Import Quick.db Database data to jsondb.ez JSON Data

const quickdb = require('quick.db')
const { Database } = require('jsondb.ez')
const db = new Database()

db.importQuick(quickdb.all())
// This will console log 'Successfully Imported!'

TO NOTE: If you imported wrong data to importQuick() that would mess your data so always enter a valid quick.db data! And remember import() is for only jsondb.ez Json data only not for Quick.db! And the most thing is Quick.db data importing sometimes will have error coz its been parsed to JSON whereas Quick.db data is not in JSON format

Some QNA

Q. Why jsondb.ez?

First this is database can store data and have more options and you can customize database but if you are using this for something large scale i prefer you to use Sqlite database but its still your choice what to use?

Q. How to clear my jsondb.ez data when i restart programm?

You can simply do that by selecting clearOnStart option. Example code given below:

const options = {
  filename: 'kek',
  clearOnStart: true
}

const { Database } = require('jsondb.ez')
const db = new Database(options)

Q. How to import my jsondb.ez from my second file whereas my main file is something other?

Its simple! Lets assume that your main file is kek.json and the old file is database.json

const { Database } = require('jsondb.ez')
const olddb = new Database({filename: 'kek'})
const newdb = new Database({filename: 'database'}) 

// This will import only database made by jsondb.ez only not other!
newdb.import(olddb.all())

Q. I use quick.db but i wish to use jsondb.ez but my Json.sqlite has some important data. How shall i import it to jsondb.ez?

Its quite easy to do. You need to use importQuick() function. Example given above!

Q. I cannot find my question above? How shall i ask some?

You can join our discord server and report it. Link is in below!

Join our Discord Server

https://discord.gg/FrduEZd

Made by Science Spot