@wxn0brp/db-core 0.6.1 → 0.7.0
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/actions.d.ts +1 -1
- package/dist/base/actions.js +4 -4
- package/dist/db/valthera.d.ts +3 -0
- package/dist/db/valthera.js +3 -0
- package/dist/helpers/collection.d.ts +4 -1
- package/dist/helpers/collection.js +3 -0
- package/dist/types/action.d.ts +1 -1
- package/dist/types/query.d.ts +3 -2
- package/dist/types/valthera.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/base/actions.d.ts
CHANGED
|
@@ -17,5 +17,5 @@ export declare abstract class ActionsBase implements ActionsBaseInterface {
|
|
|
17
17
|
abstract removeOne(config: VQuery): Promise<DataInternal | null>;
|
|
18
18
|
abstract removeCollection(config: VQuery): Promise<boolean>;
|
|
19
19
|
updateOneOrAdd(config: VQuery): Promise<DataInternal>;
|
|
20
|
-
toggleOne(config: VQuery): Promise<
|
|
20
|
+
toggleOne(config: VQuery): Promise<boolean>;
|
|
21
21
|
}
|
package/dist/base/actions.js
CHANGED
|
@@ -16,13 +16,13 @@ export class ActionsBase {
|
|
|
16
16
|
}
|
|
17
17
|
async toggleOne(config) {
|
|
18
18
|
const res = await this.removeOne(config);
|
|
19
|
-
const controlData = {
|
|
19
|
+
const controlData = { data: res };
|
|
20
20
|
config.control ||= {};
|
|
21
21
|
config.control.toggleOne = controlData;
|
|
22
22
|
if (res)
|
|
23
|
-
return
|
|
23
|
+
return false;
|
|
24
24
|
setDataForToggleOne(config);
|
|
25
|
-
config.control.toggleOne.
|
|
26
|
-
return
|
|
25
|
+
config.control.toggleOne.data = await this.add(config);
|
|
26
|
+
return true;
|
|
27
27
|
}
|
|
28
28
|
}
|
package/dist/db/valthera.d.ts
CHANGED
|
@@ -72,6 +72,9 @@ export declare class ValtheraClass implements ValtheraCompatible {
|
|
|
72
72
|
updateOneOrAdd<T = Data>(query: UpdateOneOrAddQuery): Promise<T>;
|
|
73
73
|
/**
|
|
74
74
|
* Asynchronously removes one entry in a database or adds a new one if it doesn't exist. Usage e.g. for toggling a flag.
|
|
75
|
+
* Returns a promise resolving to `false` if the entry was found and removed,
|
|
76
|
+
* or `true` if the entry was added. The returned value reflects the state of the database
|
|
77
|
+
* after the operation.
|
|
75
78
|
*/
|
|
76
79
|
toggleOne<T = Data>(query: ToggleOneQuery): Promise<T>;
|
|
77
80
|
/**
|
package/dist/db/valthera.js
CHANGED
|
@@ -129,6 +129,9 @@ export class ValtheraClass {
|
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
131
|
* Asynchronously removes one entry in a database or adds a new one if it doesn't exist. Usage e.g. for toggling a flag.
|
|
132
|
+
* Returns a promise resolving to `false` if the entry was found and removed,
|
|
133
|
+
* or `true` if the entry was added. The returned value reflects the state of the database
|
|
134
|
+
* after the operation.
|
|
132
135
|
*/
|
|
133
136
|
toggleOne(query) {
|
|
134
137
|
query.data ||= {};
|
|
@@ -44,6 +44,9 @@ export declare class Collection<D = Data> {
|
|
|
44
44
|
updateOneOrAdd(search: Search<D>, updater: Updater<D>, { add_arg, context, id_gen }?: UpdateOneOrAdd<D>): Promise<D>;
|
|
45
45
|
/**
|
|
46
46
|
* Asynchronously removes one entry in a database or adds a new one if it doesn't exist. Usage e.g. for toggling a flag.
|
|
47
|
+
* Returns a promise resolving to `false` if the entry was found and removed,
|
|
48
|
+
* or `true` if the entry was added. The returned value reflects the state of the database
|
|
49
|
+
* after the operation.
|
|
47
50
|
*/
|
|
48
|
-
toggleOne(search: Search<D>, data?: Arg<D>, context?: VContext): Promise<
|
|
51
|
+
toggleOne(search: Search<D>, data?: Arg<D>, context?: VContext): Promise<boolean>;
|
|
49
52
|
}
|
|
@@ -52,6 +52,9 @@ export class Collection {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Asynchronously removes one entry in a database or adds a new one if it doesn't exist. Usage e.g. for toggling a flag.
|
|
55
|
+
* Returns a promise resolving to `false` if the entry was found and removed,
|
|
56
|
+
* or `true` if the entry was added. The returned value reflects the state of the database
|
|
57
|
+
* after the operation.
|
|
55
58
|
*/
|
|
56
59
|
toggleOne(search, data = {}, context = {}) {
|
|
57
60
|
return this.db.toggleOne({ collection: this.collection, search, data, context });
|
package/dist/types/action.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ export interface ActionsBaseInterface {
|
|
|
16
16
|
removeOne(config: VQuery): Promise<DataInternal | null>;
|
|
17
17
|
removeCollection(config: VQuery): Promise<boolean>;
|
|
18
18
|
updateOneOrAdd(config: VQuery): Promise<DataInternal>;
|
|
19
|
-
toggleOne(config: VQuery): Promise<
|
|
19
|
+
toggleOne(config: VQuery): Promise<boolean>;
|
|
20
20
|
}
|
package/dist/types/query.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { VContext } from "./types.js";
|
|
2
1
|
import { Arg, Search, Updater } from "./arg.js";
|
|
2
|
+
import { Data } from "./data.js";
|
|
3
3
|
import { DbFindOpts, FindOpts } from "./options.js";
|
|
4
|
+
import { VContext } from "./types.js";
|
|
4
5
|
/**
|
|
5
6
|
* To extend via adapters
|
|
6
7
|
* @example
|
|
@@ -15,7 +16,7 @@ export interface VQuery_Control {
|
|
|
15
16
|
updated?: boolean;
|
|
16
17
|
};
|
|
17
18
|
toggleOne?: {
|
|
18
|
-
|
|
19
|
+
data?: Data;
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
export interface VQuery {
|
package/dist/types/valthera.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export interface ValtheraCompatible {
|
|
|
25
25
|
removeOne<T = Data>(query: RemoveQuery): Promise<T | null>;
|
|
26
26
|
removeCollection(collection: string): Promise<boolean>;
|
|
27
27
|
updateOneOrAdd<T = Data>(query: UpdateOneOrAddQuery): Promise<T>;
|
|
28
|
-
toggleOne
|
|
28
|
+
toggleOne(query: ToggleOneQuery): Promise<boolean>;
|
|
29
29
|
}
|
|
30
30
|
export interface UpdateOneOrAdd<T> {
|
|
31
31
|
add_arg?: Arg<T>;
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.
|
|
1
|
+
export const version = "0.7.0";
|