inibase 1.0.0-rc.21 â 1.0.0-rc.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -22
- package/dist/index.js +16 -6
- package/dist/utils.js +1 -1
- package/dist/utils.server.d.ts +2 -2
- package/package.json +35 -34
package/README.md
CHANGED
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
- **Lightweight** ðŠķ
|
|
11
|
+
- **Lightweight** ðŠķ
|
|
12
12
|
- **Minimalist** :white_circle:
|
|
13
13
|
- **TypeScript** :large_blue_diamond:
|
|
14
|
-
- **Super-Fast** :
|
|
14
|
+
- **Super-Fast** :zap:
|
|
15
|
+
- **Form-validation** included :sunglasses:
|
|
15
16
|
- **Suitable for large data** :page_with_curl:
|
|
16
17
|
- **Safe** :lock:
|
|
17
|
-
- **Easy to use** :
|
|
18
|
+
- **Easy to use** :bread:
|
|
18
19
|
- **...** and much more :rocket:
|
|
19
20
|
|
|
20
21
|
## Usage
|
|
@@ -40,13 +41,6 @@ const users = await db.get("user", { favoriteFoods: "![]Pizza" });
|
|
|
40
41
|
|
|
41
42
|
If you like Inibase, please sponsor: [GitHub Sponsors](https://github.com/sponsors/inicontent) || [Paypal](https://paypal.me/KarimAmahtil).
|
|
42
43
|
|
|
43
|
-
## Sponsors
|
|
44
|
-
|
|
45
|
-
<br>
|
|
46
|
-
<br>
|
|
47
|
-
|
|
48
|
-
Become a sponsor and have your company logo here ð [GitHub Sponsors](https://github.com/sponsors/inicontent) || [paypal](https://paypal.me/KarimAmahtil).
|
|
49
|
-
|
|
50
44
|
## Install
|
|
51
45
|
|
|
52
46
|
```js
|
|
@@ -55,20 +49,27 @@ Become a sponsor and have your company logo here ð [GitHub Sponsors](https://
|
|
|
55
49
|
|
|
56
50
|
## How it works?
|
|
57
51
|
|
|
58
|
-
To
|
|
52
|
+
To simplify the idea, each database has tables, each table has columns, each column will be stored in a seperated file. When POSTing new data, it will be appended to the end of each file as new line. When GETing data, the file will be readed line-by-line so it can handle large data (without consuming a lot of resources), when PUTing(updating) in a specific column, only one file will be opened and updated
|
|
59
53
|
|
|
60
54
|
## Benchmark
|
|
61
|
-
|
|
62
|
-
Bulk
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
55
|
+
|
|
56
|
+
### Bulk
|
|
57
|
+
|
|
58
|
+
| | 10 | 100 | 1000 |
|
|
59
|
+
|--------|-----------------|-----------------|-----------------|
|
|
60
|
+
| POST | 11 ms (0.65 mb) | 19 ms (1.00 mb) | 85 ms (4.58 mb) |
|
|
61
|
+
| GET | 14 ms (2.77 mb) | 12 ms (3.16 mb) | 34 ms (1.38 mb) |
|
|
62
|
+
| PUT | 6 ms (1.11 mb) | 5 ms (1.37 mb) | 10 ms (1.12 mb) |
|
|
63
|
+
| DELETE | 17 ms (1.68 mb) | 14 ms (5.45 mb) | 25 ms (5.94 mb) |
|
|
64
|
+
|
|
65
|
+
### Single
|
|
66
|
+
|
|
67
|
+
| | 10 | 100 | 1000 |
|
|
68
|
+
|--------|-------------------|--------------------|--------------------|
|
|
69
|
+
| POST | 43 ms (4.70 mb) | 387 ms (6.36 mb) | 5341 ms (24.73 mb) |
|
|
70
|
+
| GET | 99 ms (12.51 mb) | 846 ms (30.68 mb) | 7103 ms (30.86 mb) |
|
|
71
|
+
| PUT | 33 ms (10.29 mb) | 312 ms (11.06 mb) | 3539 ms (14.87 mb) |
|
|
72
|
+
| DELETE | 134 ms (13.50 mb) | 1224 ms (16.57 mb) | 7339 ms (11.46 mb) |
|
|
72
73
|
|
|
73
74
|
## Examples
|
|
74
75
|
|
package/dist/index.js
CHANGED
|
@@ -449,8 +449,7 @@ export default class Inibase {
|
|
|
449
449
|
switch (value[0]) {
|
|
450
450
|
case ">":
|
|
451
451
|
case "<":
|
|
452
|
-
|
|
453
|
-
return ["=", "]", "*"].includes(value[1])
|
|
452
|
+
return value[1] === "="
|
|
454
453
|
? [
|
|
455
454
|
value.slice(0, 2),
|
|
456
455
|
value.slice(2),
|
|
@@ -459,6 +458,13 @@ export default class Inibase {
|
|
|
459
458
|
value.slice(0, 1),
|
|
460
459
|
value.slice(1),
|
|
461
460
|
];
|
|
461
|
+
case "[":
|
|
462
|
+
return value[1] === "]"
|
|
463
|
+
? [
|
|
464
|
+
value.slice(0, 2),
|
|
465
|
+
value.slice(2).toString().split(","),
|
|
466
|
+
]
|
|
467
|
+
: ["[]", value.slice(1)];
|
|
462
468
|
case "!":
|
|
463
469
|
return ["=", "*"].includes(value[1])
|
|
464
470
|
? [
|
|
@@ -679,10 +685,14 @@ export default class Inibase {
|
|
|
679
685
|
};
|
|
680
686
|
return onlyOne && Array.isArray(RETURN) ? RETURN[0] : RETURN;
|
|
681
687
|
}
|
|
682
|
-
async post(tableName, data, options
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
688
|
+
async post(tableName, data, options, returnPostedData) {
|
|
689
|
+
if (!options)
|
|
690
|
+
options = {
|
|
691
|
+
page: 1,
|
|
692
|
+
per_page: 15,
|
|
693
|
+
};
|
|
694
|
+
if (!returnPostedData)
|
|
695
|
+
returnPostedData = false;
|
|
686
696
|
const schema = await this.getTableSchema(tableName);
|
|
687
697
|
let RETURN;
|
|
688
698
|
if (!schema)
|
package/dist/utils.js
CHANGED
|
@@ -7,7 +7,7 @@ export const isObject = (obj) => obj != null &&
|
|
|
7
7
|
export const deepMerge = (target, source) => {
|
|
8
8
|
for (const key in source) {
|
|
9
9
|
if (source.hasOwnProperty(key)) {
|
|
10
|
-
if (source[key]
|
|
10
|
+
if (isObject(source[key]) && isObject(target[key]))
|
|
11
11
|
target[key] = deepMerge(target[key], source[key]);
|
|
12
12
|
else
|
|
13
13
|
target[key] = source[key];
|
package/dist/utils.server.d.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import { type Schema } from "./index.js";
|
|
3
3
|
export declare const hashPassword: (password: string) => string;
|
|
4
4
|
export declare const comparePassword: (hashedPassword: string, inputPassword: string) => boolean;
|
|
5
|
-
export declare const encodeID: (id: number, secretKeyOrSalt: string | number | Buffer) => string;
|
|
5
|
+
export declare const encodeID: (id: number | string, secretKeyOrSalt: string | number | Buffer) => string;
|
|
6
6
|
export declare const decodeID: (input: string, secretKeyOrSalt: string | number | Buffer) => number;
|
|
7
7
|
export declare const findLastIdNumber: (schema: Schema, secretKeyOrSalt: string | number | Buffer) => number;
|
|
8
8
|
export declare const addIdToSchema: (schema: Schema, oldIndex: number, secretKeyOrSalt: string | number | Buffer) => import("./index.js").Field[];
|
|
9
9
|
export default class UtilsServer {
|
|
10
|
-
static encodeID: (id: number, secretKeyOrSalt: string | number | Buffer) => string;
|
|
10
|
+
static encodeID: (id: string | number, secretKeyOrSalt: string | number | Buffer) => string;
|
|
11
11
|
static decodeID: (input: string, secretKeyOrSalt: string | number | Buffer) => number;
|
|
12
12
|
static hashPassword: (password: string) => string;
|
|
13
13
|
static comparePassword: (hashedPassword: string, inputPassword: string) => boolean;
|
package/package.json
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inibase",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.0-rc.23",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "Karim Amahtil",
|
|
6
|
+
"email": "karim.amahtil@gmail.com"
|
|
7
|
+
},
|
|
8
|
+
"repository": "inicontent/inibase",
|
|
5
9
|
"main": "./dist/index.js",
|
|
6
|
-
"
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./dist/index.js",
|
|
12
|
+
"./file": "./dist/file.js",
|
|
13
|
+
"./utils": "./dist/utils.js",
|
|
14
|
+
"./utils.server": "./dist/utils.server.js"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/inicontent/inibase/issues"
|
|
18
|
+
},
|
|
19
|
+
"description": "NoSQL & NoJSON File-based Relational Database",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=16"
|
|
22
|
+
},
|
|
7
23
|
"files": [
|
|
8
24
|
"/dist"
|
|
9
25
|
],
|
|
10
|
-
"
|
|
11
|
-
"
|
|
26
|
+
"funding": "https://github.com/sponsors/inicontent",
|
|
27
|
+
"homepage": "https://github.com/inicontent/inibase#readme",
|
|
12
28
|
"keywords": [
|
|
13
|
-
"db",
|
|
14
29
|
"nosql",
|
|
30
|
+
"sqlite",
|
|
31
|
+
"postgresql",
|
|
32
|
+
"database",
|
|
33
|
+
"supabase",
|
|
34
|
+
"pocketbase",
|
|
35
|
+
"firebase",
|
|
36
|
+
"db",
|
|
15
37
|
"mongoose",
|
|
16
38
|
"mongodb",
|
|
17
|
-
"database",
|
|
18
39
|
"relational",
|
|
19
40
|
"local",
|
|
20
41
|
"storage",
|
|
21
42
|
"json",
|
|
22
|
-
"sql"
|
|
23
|
-
"sqlite",
|
|
24
|
-
"supabase",
|
|
25
|
-
"pocketbase",
|
|
26
|
-
"firebase"
|
|
43
|
+
"sql"
|
|
27
44
|
],
|
|
28
|
-
"author": {
|
|
29
|
-
"name": "Karim Amahtil",
|
|
30
|
-
"email": "karim.amahtil@gmail.com"
|
|
31
|
-
},
|
|
32
|
-
"funding": "https://github.com/sponsors/inicontent",
|
|
33
45
|
"license": "MIT",
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
"homepage": "https://github.com/inicontent/inibase#readme",
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@types/node": "^20.10.0",
|
|
40
|
-
"typescript": "^5.3.2"
|
|
41
|
-
},
|
|
42
|
-
"exports": {
|
|
43
|
-
".": "./dist/index.js",
|
|
44
|
-
"./file": "./dist/file.js",
|
|
45
|
-
"./utils": "./dist/utils.js",
|
|
46
|
-
"./utils.server": "./dist/utils.server.js"
|
|
47
|
-
},
|
|
46
|
+
"type": "module",
|
|
47
|
+
"types": "./dist",
|
|
48
48
|
"typesVersions": {
|
|
49
49
|
"*": {
|
|
50
50
|
"file": [
|
|
@@ -58,12 +58,13 @@
|
|
|
58
58
|
]
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
|
-
"
|
|
62
|
-
"node": "
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/node": "^20.10.4",
|
|
63
|
+
"typescript": "^5.3.3"
|
|
63
64
|
},
|
|
64
65
|
"scripts": {
|
|
65
66
|
"build": "npx tsc",
|
|
66
67
|
"test": "npx tsx watch ./text/index",
|
|
67
|
-
"benchmark": "npx tsx watch ./benchmark.ts"
|
|
68
|
+
"benchmark": "npx tsx watch --expose-gc ./benchmark.ts"
|
|
68
69
|
}
|
|
69
70
|
}
|