jsondb/README.md

32 lines
616 B
Markdown
Raw Normal View History

2022-07-16 20:30:44 +00:00
# jsondb
`jsondb` is a way to use JSON as a NoSQL database. It uses an ORM and is the only way to interact with the database.
## Loading a database
All you need to do is to use `loadDB`. Here is an example:
```javascript
2022-08-05 19:10:54 +00:00
let { DB } = require("jsondb");
let db = new DB("db.json");
2022-07-16 20:30:44 +00:00
```
## Setting values
You do it just like any JavaScript object. Here is an example:
```javascript
2022-08-05 19:10:54 +00:00
db.v["bits"] = 64;
db.v.bits = 64; // this also works
db.update();
2022-07-16 20:30:44 +00:00
```
## Getting values
Again, it's just like any JS object. Here is an example:
```javascript
2022-08-05 19:10:54 +00:00
let bits = db.v["bits"];
bits = db.v.bits; // that also works
2022-07-16 20:30:44 +00:00
```