Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsondb.ez

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsondb.ez

Simple database which stores data in JSON files!

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 31 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc