@wxn0brp/db-core 0.3.0-alpha.0 → 0.3.1
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/valthera.d.ts
CHANGED
|
@@ -18,7 +18,11 @@ type DbActionsFns = keyof {
|
|
|
18
18
|
declare class ValtheraClass implements ValtheraCompatible {
|
|
19
19
|
dbAction: ActionsBase;
|
|
20
20
|
executor: executorC;
|
|
21
|
-
emiter: VEE
|
|
21
|
+
emiter: VEE<{
|
|
22
|
+
[K in Exclude<DbActionsFns, "init">]: (query: VQuery, result: Awaited<ReturnType<ValtheraCompatible[K]>>) => void;
|
|
23
|
+
} & {
|
|
24
|
+
"*": (name: DbActionsFns, query: VQuery, result: any) => void;
|
|
25
|
+
}>;
|
|
22
26
|
version: string;
|
|
23
27
|
constructor(options?: DbOpts);
|
|
24
28
|
init(...args: any[]): Promise<unknown>;
|
package/dist/db/valthera.js
CHANGED
|
@@ -33,9 +33,8 @@ class ValtheraClass {
|
|
|
33
33
|
async execute(name, query) {
|
|
34
34
|
await this.init();
|
|
35
35
|
const result = await this.executor.addOp(this.dbAction[name].bind(this.dbAction), query);
|
|
36
|
-
|
|
37
|
-
this.emiter.emit(name,
|
|
38
|
-
this.emiter.emit("*", name, emitArgs, result);
|
|
36
|
+
this.emiter.emit(name, query, result);
|
|
37
|
+
this.emiter.emit("*", name, query, result);
|
|
39
38
|
return result;
|
|
40
39
|
}
|
|
41
40
|
/**
|
|
@@ -38,7 +38,7 @@ declare class CollectionManager<D = Data> {
|
|
|
38
38
|
/**
|
|
39
39
|
* Asynchronously updates one entry in a database or adds a new one if it doesn't exist.
|
|
40
40
|
*/
|
|
41
|
-
updateOneOrAdd<T = Data>(search: Search<T & D>, updater: Updater<T & D>, { add_arg, context, id_gen }
|
|
41
|
+
updateOneOrAdd<T = Data>(search: Search<T & D>, updater: Updater<T & D>, { add_arg, context, id_gen }?: UpdateOneOrAdd<T & D>): Promise<boolean>;
|
|
42
42
|
/**
|
|
43
43
|
* Asynchronously removes one entry in a database or adds a new one if it doesn't exist. Usage e.g. for toggling a flag.
|
|
44
44
|
*/
|
|
@@ -50,7 +50,7 @@ class CollectionManager {
|
|
|
50
50
|
/**
|
|
51
51
|
* Asynchronously updates one entry in a database or adds a new one if it doesn't exist.
|
|
52
52
|
*/
|
|
53
|
-
async updateOneOrAdd(search, updater, { add_arg = {}, context = {}, id_gen = true }) {
|
|
53
|
+
async updateOneOrAdd(search, updater, { add_arg = {}, context = {}, id_gen = true } = {}) {
|
|
54
54
|
return await this.db.updateOneOrAdd(this.collection, search, updater, { add_arg, context, id_gen });
|
|
55
55
|
}
|
|
56
56
|
/**
|
package/dist/utils/action.js
CHANGED
|
@@ -40,8 +40,13 @@ export async function findUtil(query, fileCpu, files) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
if (sortBy) {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
if (sortBy === "random()") {
|
|
44
|
+
datas.sort(() => Math.random() - 0.5);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const dir = sortAsc ? 1 : -1;
|
|
48
|
+
datas.sort((a, b) => compareSafe(a[sortBy], b[sortBy]) * dir);
|
|
49
|
+
}
|
|
45
50
|
const start = offset;
|
|
46
51
|
const end = limit !== -1 ? offset + limit : undefined;
|
|
47
52
|
datas = datas.slice(start, end);
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.3.
|
|
1
|
+
export const version = "0.3.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wxn0brp/db-core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"types": "dist/index.d.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "wxn0brP",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"homepage": "https://github.com/wxn0brP/ValtheraDB",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@wxn0brp/event-emitter": "^0.0.
|
|
16
|
+
"@wxn0brp/event-emitter": "^0.0.4"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/bun": "*",
|