0.0.2 • Published 3 years ago

ckn.db v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

ckn.db V0.0.2

An easy database and easy to use. Data is stored in a json file on your server!

Installation

  • npm install ckn.db@latest

Triggers

  • db.set('value', { value: '1' }
  • db.add("value", 1)
  • db.sub("value", 1)
  • db.push("value", {value: "1"} )
  • db.get("value")
  • db.delete("value")
  • db.all()
  • db.clear()

Examples

const Database = require("ckn.db");
const db = new Database("./ckn.json");

db.set('status', { status: 'Online' })
/*
JSON Output:
{
  "status": {
    "status": "Online"
  }
}
*/
db.set('status', { status: 'Offline'})
/*
JSON Output:
{
  "status": {
    "status": "Offline"
  }
}
*/

db.set('money', {userid: '0'})
/*
JSON Output:
{
  "money": {
    "userid": "0"
  }
}
*/

db.add('money', {userid: '5'})
/*
JSON Output:
{
  "money": {
    "userid": "5"
  }
}
*/

db.sub('money', {userid: '5'})
/*
JSON Output:
{
  "money": {
    "userid": "0"
  }
}
*/

db.has("money", {userid: '0'}) // Output: true
db.has("money", {userid: '5'}) // Output: false

console.log(db.all()) // Get the json file

db.delete("money", {userid}) // Deleting the Users money

db.clear() // Clears the database