@wxn0brp/db-core 0.11.0-alpha.2 → 0.11.0-alpha.3
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/base/custom.d.ts +4 -4
- package/dist/customFileCpu.d.ts +4 -4
- package/dist/customFileCpu.js +6 -6
- package/dist/utils/process.d.ts +4 -4
- package/dist/utils/process.js +4 -4
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/base/custom.d.ts
CHANGED
|
@@ -20,17 +20,17 @@ export declare abstract class CustomActionsBase extends ActionsBase {
|
|
|
20
20
|
/**
|
|
21
21
|
* Update entries in the specified database based on search criteria and an updater function or object.
|
|
22
22
|
*/
|
|
23
|
-
update(query: VQueryT.Update): Promise<
|
|
23
|
+
update(query: VQueryT.Update): Promise<import("../types/data.js").DataInternal[]>;
|
|
24
24
|
/**
|
|
25
25
|
* Update the first matching entry in the specified database based on search criteria and an updater function or object.
|
|
26
26
|
*/
|
|
27
|
-
updateOne(query: VQueryT.Update): Promise<
|
|
27
|
+
updateOne(query: VQueryT.Update): Promise<import("../types/data.js").DataInternal>;
|
|
28
28
|
/**
|
|
29
29
|
* Remove entries from the specified database based on search criteria.
|
|
30
30
|
*/
|
|
31
|
-
remove(query: VQueryT.Remove): Promise<
|
|
31
|
+
remove(query: VQueryT.Remove): Promise<import("../types/data.js").DataInternal[]>;
|
|
32
32
|
/**
|
|
33
33
|
* Remove the first matching entry from the specified database based on search criteria.
|
|
34
34
|
*/
|
|
35
|
-
removeOne(query: VQueryT.Remove): Promise<
|
|
35
|
+
removeOne(query: VQueryT.Remove): Promise<import("../types/data.js").DataInternal>;
|
|
36
36
|
}
|
package/dist/customFileCpu.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Data } from "./types/data.js";
|
|
1
|
+
import { Data, DataInternal } from "./types/data.js";
|
|
2
2
|
import { FileCpu } from "./types/fileCpu.js";
|
|
3
3
|
import { VQueryT } from "./types/query.js";
|
|
4
4
|
export type WriteFile = (file: string, data: any[]) => Promise<void>;
|
|
@@ -10,7 +10,7 @@ export declare class CustomFileCpu implements FileCpu {
|
|
|
10
10
|
constructor(readFile: ReadFile, writeFile: WriteFile);
|
|
11
11
|
add(file: string, config: VQueryT.Add): Promise<void>;
|
|
12
12
|
find(file: string, config: VQueryT.Find): Promise<Data[]>;
|
|
13
|
-
findOne(file: string, config: VQueryT.FindOne): Promise<
|
|
14
|
-
remove(file: string, config: VQueryT.Remove, one: boolean): Promise<
|
|
15
|
-
update(file: string, config: VQueryT.Update, one: boolean): Promise<
|
|
13
|
+
findOne(file: string, config: VQueryT.FindOne): Promise<DataInternal | false>;
|
|
14
|
+
remove(file: string, config: VQueryT.Remove, one: boolean): Promise<DataInternal[]>;
|
|
15
|
+
update(file: string, config: VQueryT.Update, one: boolean): Promise<DataInternal[]>;
|
|
16
16
|
}
|
package/dist/customFileCpu.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { matchObj, findObj, updateObj } from "./utils/process.js";
|
|
2
2
|
export function pathRepair(path) {
|
|
3
3
|
return path.replaceAll("//", "/");
|
|
4
4
|
}
|
|
@@ -19,14 +19,14 @@ export class CustomFileCpu {
|
|
|
19
19
|
file = pathRepair(file);
|
|
20
20
|
const entries = await this._readFile(file);
|
|
21
21
|
return entries
|
|
22
|
-
.map((entry) =>
|
|
22
|
+
.map((entry) => findObj(config, entry))
|
|
23
23
|
.filter(Boolean);
|
|
24
24
|
}
|
|
25
25
|
async findOne(file, config) {
|
|
26
26
|
file = pathRepair(file);
|
|
27
27
|
const entries = await this._readFile(file);
|
|
28
28
|
for (const entry of entries) {
|
|
29
|
-
const result =
|
|
29
|
+
const result = findObj(config, entry);
|
|
30
30
|
if (result)
|
|
31
31
|
return result;
|
|
32
32
|
}
|
|
@@ -39,7 +39,7 @@ export class CustomFileCpu {
|
|
|
39
39
|
entries = entries.filter((entry) => {
|
|
40
40
|
if (removed.length && one)
|
|
41
41
|
return true;
|
|
42
|
-
if (
|
|
42
|
+
if (matchObj(config, entry)) {
|
|
43
43
|
removed.push(entry);
|
|
44
44
|
return false;
|
|
45
45
|
}
|
|
@@ -56,8 +56,8 @@ export class CustomFileCpu {
|
|
|
56
56
|
entries = entries.map((entry) => {
|
|
57
57
|
if (updated.length && one)
|
|
58
58
|
return entry;
|
|
59
|
-
if (
|
|
60
|
-
const updatedEntry =
|
|
59
|
+
if (matchObj(config, entry)) {
|
|
60
|
+
const updatedEntry = updateObj(config, entry);
|
|
61
61
|
updated.push(updatedEntry);
|
|
62
62
|
return updatedEntry;
|
|
63
63
|
}
|
package/dist/utils/process.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Data } from "../types/data.js";
|
|
1
|
+
import { Data, DataInternal } from "../types/data.js";
|
|
2
2
|
import { VQuery, VQueryT } from "../types/query.js";
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
3
|
+
export declare function findObj(config: VQueryT.Find | VQueryT.FindOne, obj: Data): DataInternal | null;
|
|
4
|
+
export declare function matchObj(config: VQuery, obj: Data): boolean;
|
|
5
|
+
export declare function updateObj(config: VQueryT.Update, obj: Data): DataInternal;
|
package/dist/utils/process.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { hasFieldsAdvanced } from "./hasFieldsAdvanced.js";
|
|
2
2
|
import { updateFindObject } from "./updateFindObject.js";
|
|
3
3
|
import { updateObjectAdvanced } from "./updateObject.js";
|
|
4
|
-
export function
|
|
5
|
-
if (
|
|
4
|
+
export function findObj(config, obj) {
|
|
5
|
+
if (matchObj(config, obj))
|
|
6
6
|
return updateFindObject(obj, config.findOpts || {});
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
|
-
export function
|
|
9
|
+
export function matchObj(config, obj) {
|
|
10
10
|
const { search, context } = config;
|
|
11
11
|
if (search === undefined || search === null)
|
|
12
12
|
return true;
|
|
@@ -16,7 +16,7 @@ export function match(config, obj) {
|
|
|
16
16
|
return true;
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
|
-
export function
|
|
19
|
+
export function updateObj(config, obj) {
|
|
20
20
|
const { updater, context } = config;
|
|
21
21
|
if (typeof updater === "object" && !Array.isArray(updater))
|
|
22
22
|
return updateObjectAdvanced(obj, updater);
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.11.0-alpha.
|
|
1
|
+
export const version = "0.11.0-alpha.3";
|