@wxn0brp/db-core 0.1.2 → 0.1.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/db/memory.js +1 -1
- package/dist/db/valthera.d.ts +5 -1
- package/dist/db/valthera.js +6 -5
- package/dist/{utils → helpers}/forge.d.ts +1 -1
- package/dist/{utils → helpers}/forge.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/utils/sortId.d.ts +3 -0
- package/dist/utils/sortId.js +7 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/db/memory.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CustomActionsBase } from "../base/custom.js";
|
|
2
2
|
import CustomFileCpu from "../customFileCpu.js";
|
|
3
|
-
import { forgeValthera } from "../
|
|
3
|
+
import { forgeValthera } from "../helpers/forge.js";
|
|
4
4
|
import ValtheraClass from "./valthera.js";
|
|
5
5
|
export class MemoryAction extends CustomActionsBase {
|
|
6
6
|
memory;
|
package/dist/db/valthera.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ import Data from "../types/data.js";
|
|
|
7
7
|
import { DbOpts, DbFindOpts, FindOpts } from "../types/options.js";
|
|
8
8
|
import { VContext } from "../types/types.js";
|
|
9
9
|
import { ValtheraCompatible } from "../types/valthera.js";
|
|
10
|
+
import { VQuery } from "../types/query.js";
|
|
11
|
+
type DbActionsFns = keyof {
|
|
12
|
+
[K in keyof ActionsBase as ActionsBase[K] extends (...args: any[]) => any ? K : never]: any;
|
|
13
|
+
};
|
|
10
14
|
/**
|
|
11
15
|
* Represents a database management class for performing CRUD operations.
|
|
12
16
|
* @class
|
|
@@ -18,7 +22,7 @@ declare class ValtheraClass implements ValtheraCompatible {
|
|
|
18
22
|
version: string;
|
|
19
23
|
constructor(options?: DbOpts);
|
|
20
24
|
init(...args: any[]): Promise<unknown>;
|
|
21
|
-
|
|
25
|
+
execute<T>(name: DbActionsFns, query: VQuery): Promise<T>;
|
|
22
26
|
/**
|
|
23
27
|
* Create a new instance of a CollectionManager class.
|
|
24
28
|
*/
|
package/dist/db/valthera.js
CHANGED
|
@@ -28,11 +28,12 @@ class ValtheraClass {
|
|
|
28
28
|
self.dbAction._inited = true;
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
async execute(name,
|
|
31
|
+
async execute(name, query) {
|
|
32
32
|
await this.init();
|
|
33
|
-
const result = await this.executor.addOp(this.dbAction[name].bind(this.dbAction),
|
|
34
|
-
|
|
35
|
-
this.emiter.emit(
|
|
33
|
+
const result = await this.executor.addOp(this.dbAction[name].bind(this.dbAction), query);
|
|
34
|
+
const emitArgs = Array.from(arguments).slice(1);
|
|
35
|
+
this.emiter.emit(name, emitArgs, result);
|
|
36
|
+
this.emiter.emit("*", name, emitArgs, result);
|
|
36
37
|
return result;
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
@@ -45,7 +46,7 @@ class ValtheraClass {
|
|
|
45
46
|
* Get the names of all available databases.
|
|
46
47
|
*/
|
|
47
48
|
async getCollections() {
|
|
48
|
-
return await this.execute("getCollections");
|
|
49
|
+
return await this.execute("getCollections", {});
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* Check and create the specified collection if it doesn't exist.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import CollectionManager from "
|
|
1
|
+
import CollectionManager from "./CollectionManager.js";
|
|
2
2
|
import Data from "../types/data.js";
|
|
3
3
|
import { ValtheraCompatible } from "../types/valthera.js";
|
|
4
4
|
export declare function forgeValthera<T extends string>(target: ValtheraCompatible): ValtheraCompatible & { [K in T]: CollectionManager; };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ import Relation from "./helpers/relation.js";
|
|
|
6
6
|
import { ValtheraTypes } from "./types/export.js";
|
|
7
7
|
import { RelationTypes } from "./types/relation.js";
|
|
8
8
|
import { ValtheraCompatible } from "./types/valthera.js";
|
|
9
|
-
import { forgeTypedValthera, forgeValthera } from "./
|
|
10
|
-
|
|
9
|
+
import { forgeTypedValthera, forgeValthera } from "./helpers/forge.js";
|
|
10
|
+
import { sortByIds } from "./utils/sortId.js";
|
|
11
|
+
export { createMemoryValthera, CustomFileCpu, forgeTypedValthera, forgeValthera, genId, Relation, ValtheraClass, ValtheraMemory, sortByIds, };
|
|
11
12
|
export type { RelationTypes, ValtheraCompatible, ValtheraTypes, };
|
|
12
13
|
export type Id = import("./types/Id.js").Id;
|
package/dist/index.js
CHANGED
|
@@ -3,5 +3,6 @@ import ValtheraMemory, { createMemoryValthera } from "./db/memory.js";
|
|
|
3
3
|
import ValtheraClass from "./db/valthera.js";
|
|
4
4
|
import genId from "./helpers/gen.js";
|
|
5
5
|
import Relation from "./helpers/relation.js";
|
|
6
|
-
import { forgeTypedValthera, forgeValthera } from "./
|
|
7
|
-
|
|
6
|
+
import { forgeTypedValthera, forgeValthera } from "./helpers/forge.js";
|
|
7
|
+
import { sortByIds } from "./utils/sortId.js";
|
|
8
|
+
export { createMemoryValthera, CustomFileCpu, forgeTypedValthera, forgeValthera, genId, Relation, ValtheraClass, ValtheraMemory, sortByIds, };
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.1.
|
|
1
|
+
export const version = "0.1.3";
|