@wxn0brp/db-storage-dir 0.1.3 → 0.1.5
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/dist/action.d.ts +1 -1
- package/dist/action.js +3 -4
- package/dist/format.d.ts +1 -11
- package/dist/format.js +3 -17
- package/dist/version.js +1 -1
- package/package.json +4 -4
package/dist/action.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare class FileActions extends dbActionBase {
|
|
|
34
34
|
/**
|
|
35
35
|
* Add a new entry to the specified database.
|
|
36
36
|
*/
|
|
37
|
-
add({ collection, data
|
|
37
|
+
add({ collection, data }: VQuery): Promise<import("@wxn0brp/db-core/types/arg").Arg>;
|
|
38
38
|
/**
|
|
39
39
|
* Find entries in the specified database based on search criteria.
|
|
40
40
|
*/
|
package/dist/action.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import dbActionBase from "@wxn0brp/db-core/base/actions";
|
|
2
|
-
import
|
|
2
|
+
import { addId } from "@wxn0brp/db-core/helpers/addId";
|
|
3
3
|
import { findUtil } from "@wxn0brp/db-core/utils/action";
|
|
4
4
|
import { existsSync, mkdirSync, promises, statSync } from "fs";
|
|
5
5
|
import { resolve, sep } from "path";
|
|
@@ -73,12 +73,11 @@ export class FileActions extends dbActionBase {
|
|
|
73
73
|
/**
|
|
74
74
|
* Add a new entry to the specified database.
|
|
75
75
|
*/
|
|
76
|
-
async add({ collection, data
|
|
76
|
+
async add({ collection, data }) {
|
|
77
77
|
await this.ensureCollection(arguments[0]);
|
|
78
78
|
const c_path = this._getCollectionPath(collection);
|
|
79
79
|
const file = c_path + await getLastFile(c_path, this.options.maxFileSize);
|
|
80
|
-
|
|
81
|
-
data._id = data._id || gen();
|
|
80
|
+
await addId(arguments[0], this);
|
|
82
81
|
await this.fileCpu.add(file, data);
|
|
83
82
|
return data;
|
|
84
83
|
}
|
package/dist/format.d.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses given string into a JSON object. If the string does not start with
|
|
3
|
-
* a {, it is wrapped in one. This allows for a shorthand when
|
|
4
|
-
* storing/reading data from a file.
|
|
5
|
-
*/
|
|
6
1
|
export declare function parseData(data: string): any;
|
|
7
|
-
|
|
8
|
-
* Converts given object to a string. If the string is a valid json5, it is
|
|
9
|
-
* returned as is. If it is a valid json5 wrapped in {}, the curly brackets
|
|
10
|
-
* are removed. Otherwise the string is wrapped in {}.
|
|
11
|
-
*/
|
|
12
|
-
export declare function stringifyData(data: any): any;
|
|
2
|
+
export declare function stringifyData(data: any): string;
|
package/dist/format.js
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
import json5 from "json5";
|
|
2
|
-
/**
|
|
3
|
-
* Parses given string into a JSON object. If the string does not start with
|
|
4
|
-
* a {, it is wrapped in one. This allows for a shorthand when
|
|
5
|
-
* storing/reading data from a file.
|
|
6
|
-
*/
|
|
7
2
|
export function parseData(data) {
|
|
8
|
-
if (
|
|
9
|
-
|
|
3
|
+
if (data[0] !== "{")
|
|
4
|
+
return json5.parse(`{${data}}`);
|
|
10
5
|
return json5.parse(data);
|
|
11
6
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Converts given object to a string. If the string is a valid json5, it is
|
|
14
|
-
* returned as is. If it is a valid json5 wrapped in {}, the curly brackets
|
|
15
|
-
* are removed. Otherwise the string is wrapped in {}.
|
|
16
|
-
*/
|
|
17
7
|
export function stringifyData(data) {
|
|
18
|
-
|
|
19
|
-
if (data.startsWith("{")) {
|
|
20
|
-
data = data.slice(1, -1);
|
|
21
|
-
}
|
|
22
|
-
return data;
|
|
8
|
+
return json5.stringify(data);
|
|
23
9
|
}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.1.
|
|
1
|
+
export const version = "0.1.5";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wxn0brp/db-storage-dir",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "wxn0brP",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"json5": "^2.2.3"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@wxn0brp/db-core": ">=0.
|
|
19
|
+
"@wxn0brp/db-core": ">=0.4.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/bun": "*",
|
|
23
|
-
"@wxn0brp/db-core": "^0.
|
|
23
|
+
"@wxn0brp/db-core": "^0.4.0",
|
|
24
24
|
"tsc-alias": "*",
|
|
25
25
|
"typescript": "*"
|
|
26
26
|
},
|
|
@@ -39,4 +39,4 @@
|
|
|
39
39
|
"default": "./dist/*.js"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}
|