0.1.0 • Published 3 years ago
jhowdb v0.1.0
Links
See all functions below:
Functions | Examples |
---|---|
.get() | jdb.get("user") |
.add() | jdb.add("user", 100) |
.remove() | jdb.remove("user", 100) |
.set() | jdb.set("user", 50) |
.delete() | jdb.delete("user") |
.all() | jdb.all() |
.push | jdb.push("a", "b") |
Examples below:
Add
const db = require("jhowdb")
const jdb = new db("jhowdb.json") //File where it will be stored
jdb.add("user", 100)
//Or
jdb.add("user/money", 100)
Remove
const db = require("jhowdb")
const jdb = new db("jhowdb.json") //File where it will be stored
jdb.remove("user", 100)
//Or
jdb.remove("user/money", 100)
Get
const db = require("jhowdb")
const jdb = new db("jhowdb.json") //File where it will be stored
let value = jdb.get("user") //Also works the "/"
if(value === null) value = 0 //If you don't put this, or ternary, it will return null
console.log(`You have: ${value.money} coins!`)
Set
const db = require("jhowdb")
const jdb = new db("jhowdb.json") //File where it will be stored
jdb.set("guild", "Devcenter best botlist/programming server")
//Or
jdb.set("guild/info", "Devcenter best botlist/programming server")
Delete
const db = require("jhowdb")
const jdb = new db("jhowdb.json") //File where it will be stored
jdb.delete("guild")
//Or
jdb.delete("guild/info")
All
const db = require("jhowdb")
const jdb = new db("jhowdb.json") //File where it will be stored
console.log(jdb.all())