fewerapi 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fewerapi might be problematic. Click here for more details.
- package/README.md +45 -0
- package/gayy.js +1 -0
- package/index.js +25 -0
- package/package.json +59 -0
package/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
## Example
|
2
|
+
|
3
|
+
```js
|
4
|
+
const { QuickDB } = require("quick.db");
|
5
|
+
const db = new QuickDB(); // will make a json.sqlite in the root folder
|
6
|
+
// if you want to specify a path you can do so like this
|
7
|
+
// const db = new QuickDB({ filePath: "source/to/path/test.sqlite" });
|
8
|
+
|
9
|
+
(async () => {
|
10
|
+
// self calling async function just to get async
|
11
|
+
// Setting an object in the database:
|
12
|
+
await db.set("userInfo", { difficulty: "Easy" });
|
13
|
+
// -> { difficulty: 'Easy' }
|
14
|
+
|
15
|
+
// Getting an object from the database:
|
16
|
+
await db.get("userInfo");
|
17
|
+
// -> { difficulty: 'Easy' }
|
18
|
+
|
19
|
+
// Getting an object property from the database:
|
20
|
+
await db.get("userInfo.difficulty");
|
21
|
+
// -> 'Easy'
|
22
|
+
|
23
|
+
// Setting an object in the database:
|
24
|
+
await db.set("userInfo", { difficulty: "Easy" });
|
25
|
+
// -> { difficulty: 'Easy' }
|
26
|
+
|
27
|
+
// Pushing an element to an array (that doesn't exist yet) in an object:
|
28
|
+
await db.push("userInfo.items", "Sword");
|
29
|
+
// -> { difficulty: 'Easy', items: ['Sword'] }
|
30
|
+
|
31
|
+
// Adding to a number (that doesn't exist yet) in an object:
|
32
|
+
await db.add("userInfo.balance", 500);
|
33
|
+
// -> { difficulty: 'Easy', items: ['Sword'], balance: 500 }
|
34
|
+
|
35
|
+
// Repeating previous examples:
|
36
|
+
await db.push("userInfo.items", "Watch");
|
37
|
+
// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 500 }
|
38
|
+
await db.add("userInfo.balance", 500);
|
39
|
+
// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 1000 }
|
40
|
+
|
41
|
+
// Fetching individual properties
|
42
|
+
await db.get("userInfo.balance"); // -> 1000
|
43
|
+
await db.get("userInfo.items"); // ['Sword', 'Watch']
|
44
|
+
})();
|
45
|
+
```
|