2.0.3 • Published 3 months ago

clarity-db v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

npm install clarity-db

Usage

To use the library, you need to import it into your project:

const Clarity = require("clarity-db")
const db = new Clarity("./mydb.json", {
    backup: {
        enabled: true,
        folder: './db_backups/',
        interval: 3600000
    },
    preset: {
        hello: "world"
    }
})```

```js


// Check if a key exists in the database
if(db.has(`sown`)) {
    console.log("sown is registered")
} else {
    console.log("sown is not registered")
}

// Get a value from a key
let sparrow = db.get("sparrow")

console.log(sparrow) // Output: Sparrow

// Set a value for a key
db.set("bird", "Sparrow")
// Perform arithmetic operations on values
db.add("tsubasa_money", 10000)
db.sub("sparrow_money", 10000)

// Get all data from the database
db.all()```

```js
// Delete a key and its value
db.delete("bird")
// Clear all data
db.clear()

// Save changes (optional)
db.save()
// Backup the database
db.backup()
// Restore db 
db.restore('clarity-test')
// Working with arrays
let owners = db.get(`allowners`)
if(!owners){
    db.set("owners", ["tsubasa"])
} else {
    db.push("owners", "xon") //['tsubasa','xon']
}```
2.0.3

3 months ago

2.0.2

3 months ago

2.0.1

3 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago