@wxn0brp/vql-client 0.2.7 → 0.2.8
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/vql.d.ts +18 -17
- package/package.json +1 -1
package/dist/vql.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
export interface Data {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
}
|
|
4
|
-
export interface VContext {
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
}
|
|
7
1
|
export type KeysMatching<T, V, C = V> = {
|
|
8
2
|
[K in keyof T]-?: T[K] extends C ? K : never;
|
|
9
3
|
}[keyof T];
|
|
@@ -13,6 +7,7 @@ export type NestedValue<T, V, C = V> = {
|
|
|
13
7
|
export type DeepPartial<T> = {
|
|
14
8
|
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
|
|
15
9
|
};
|
|
10
|
+
export type JSPrimitiveType = "string" | "number" | "boolean" | "bigint" | "symbol" | "undefined" | "function" | "object";
|
|
16
11
|
export type LogicalOperators<T = any> = {
|
|
17
12
|
$and?: Array<SearchOptions<T>>;
|
|
18
13
|
$or?: Array<SearchOptions<T>>;
|
|
@@ -39,8 +34,8 @@ export type ComparisonOperators<T = any> = {
|
|
|
39
34
|
$idLte?: NestedValue<T, string | number, string | number>;
|
|
40
35
|
};
|
|
41
36
|
export type TypeAndExistenceOperators<T = any> = {
|
|
42
|
-
$exists?: NestedValue<T, boolean>;
|
|
43
|
-
$type?: NestedValue<T,
|
|
37
|
+
$exists?: NestedValue<T, boolean, any>;
|
|
38
|
+
$type?: NestedValue<T, JSPrimitiveType, any>;
|
|
44
39
|
};
|
|
45
40
|
export type ArrayOperators<T = any> = {
|
|
46
41
|
$arrinc?: DeepPartial<T>;
|
|
@@ -57,6 +52,9 @@ export type OtherOperators<T = any> = {
|
|
|
57
52
|
};
|
|
58
53
|
export type PredefinedSearchOperators<T = any> = LogicalOperators<T> & ComparisonOperators<T> & TypeAndExistenceOperators<T> & ArrayOperators<T> & StringOperators<T> & OtherOperators<T>;
|
|
59
54
|
export type SearchOptions<T = any> = PredefinedSearchOperators<T> & DeepPartial<T> & Record<string, any>;
|
|
55
|
+
export interface VContext {
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
}
|
|
60
58
|
export type ArrayUpdater<T = any> = {
|
|
61
59
|
$push?: NestedValue<T, any>;
|
|
62
60
|
$pushset?: NestedValue<T, any>;
|
|
@@ -82,6 +80,9 @@ export type SearchFunc<T = any> = (data: T, context: VContext) => boolean;
|
|
|
82
80
|
export type UpdaterFunc<T = any> = (data: T, context: VContext) => boolean;
|
|
83
81
|
export type Search<T = any> = SearchOptions<T> | SearchFunc<T>;
|
|
84
82
|
export type Updater<T = any> = UpdaterArg<T> | UpdaterArg<T>[] | UpdaterFunc<T>;
|
|
83
|
+
export interface Data {
|
|
84
|
+
[key: string]: any;
|
|
85
|
+
}
|
|
85
86
|
export interface DbFindOpts<T = any> {
|
|
86
87
|
reverse?: boolean;
|
|
87
88
|
limit?: number;
|
|
@@ -98,15 +99,15 @@ declare class CollectionManager<D = Data> {
|
|
|
98
99
|
private db;
|
|
99
100
|
private collection;
|
|
100
101
|
constructor(db: ValtheraCompatible, collection: string);
|
|
101
|
-
add
|
|
102
|
-
find
|
|
103
|
-
findOne
|
|
104
|
-
update
|
|
105
|
-
updateOne
|
|
106
|
-
remove
|
|
107
|
-
removeOne
|
|
108
|
-
updateOneOrAdd
|
|
109
|
-
toggleOne
|
|
102
|
+
add(data: Arg<D>, id_gen?: boolean): Promise<D>;
|
|
103
|
+
find(search?: Search<D>, options?: DbFindOpts<D>, findOpts?: FindOpts<D>, context?: VContext): Promise<D[]>;
|
|
104
|
+
findOne(search?: Search<D>, findOpts?: FindOpts<D>, context?: VContext): Promise<D>;
|
|
105
|
+
update(search: Search<D>, updater: Updater<D>, context?: VContext): Promise<boolean>;
|
|
106
|
+
updateOne(search: Search<D>, updater: Updater<D>, context?: VContext): Promise<boolean>;
|
|
107
|
+
remove(search: Search<D>, context?: VContext): Promise<boolean>;
|
|
108
|
+
removeOne(search: Search<D>, context?: VContext): Promise<boolean>;
|
|
109
|
+
updateOneOrAdd(search: Search<D>, updater: Updater<D>, { add_arg, context, id_gen }?: UpdateOneOrAdd<D>): Promise<boolean>;
|
|
110
|
+
toggleOne(search: Search<D>, data?: Arg<D>, context?: VContext): Promise<boolean>;
|
|
110
111
|
}
|
|
111
112
|
export interface ValtheraCompatible {
|
|
112
113
|
c(collection: string): CollectionManager;
|