# clarity-db

> Manage database is easy

Latest version **2.0.6** (published 2024-06-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install clarity-db
pnpm add clarity-db
yarn add clarity-db
bun add clarity-db
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2024-06-13 |
| First published | 2023-11-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 14.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | 1Tsubasa |
| Maintainers | 1tsubasa |
| Keywords | db, quick.db, json |

## Links

- npm: https://www.npmjs.com/package/clarity-db
- Repository: https://github.com/Clarity-Corp/clarity-db
- Homepage: https://github.com/Clarity-Corp/clarity-db#readme
- Issues: https://github.com/Clarity-Corp/clarity-db/issues
- npm.io page: https://npm.io/package/clarity-db

## Dependencies (9)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [pg](https://npm.io/package/pg.md) ^8.12.0
- [path](https://npm.io/package/path.md) ^0.12.7
- [tslib](https://npm.io/package/tslib.md) ^2.6.2
- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [mysql2](https://npm.io/package/mysql2.md) ^3.10.0
- [mongodb](https://npm.io/package/mongodb.md) ^6.7.0
- [sqlite3](https://npm.io/package/sqlite3.md) ^5.1.7
- [typescript](https://npm.io/package/typescript.md) ^5.3.3

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.0.6 (latest) — 2024-06-13
- 2.0.5 — 2024-06-13
- 2.0.4 — 2024-06-13
- 2.0.3 — 2024-02-05
- 2.0.2 — 2024-02-05
- 2.0.1 — 2024-02-05
- 1.0.6 — 2023-11-09
- 1.0.5 — 2023-11-09
- 1.0.4 — 2023-11-09
- 1.0.3 — 2023-11-09
- 1.0.2 — 2023-11-09
- 1.0.1 — 2023-11-09
- 1.0.0 — 2023-11-09

## README

npm install clarity-db
## Usage
To use the library, you need to import it into your project:
```js
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']
}```

---
_Source: https://npm.io/package/clarity-db · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
