@wxn0brp/vql-client 0.2.11 → 0.2.13

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.
Files changed (2) hide show
  1. package/dist/vql.d.ts +37 -50
  2. package/package.json +1 -1
package/dist/vql.d.ts CHANGED
@@ -84,13 +84,25 @@ export type Arg<T = any> = {
84
84
  [K in keyof T]?: any;
85
85
  } & Record<string, any>;
86
86
  export type SearchFunc<T = any> = (data: T, context: VContext) => boolean;
87
- export type UpdaterFunc<T = any> = (data: T, context: VContext) => boolean;
87
+ export type UpdaterFunc<T = any> = (data: T, context: VContext) => Data | void;
88
88
  export type Search<T = any> = SearchOptions<T> | SearchFunc<T>;
89
- export type Updater<T = any> = UpdaterArg<T> | UpdaterArg<T>[] | UpdaterFunc<T>;
90
- export interface UpdateOneOrAdd<T> {
91
- add_arg?: Arg<T>;
92
- id_gen?: boolean;
93
- context?: VContext;
89
+ export type Updater<T = any> = UpdaterArg<T> | UpdaterFunc<T>;
90
+ export interface DbFindOpts<T = any> {
91
+ reverse?: boolean;
92
+ limit?: number;
93
+ offset?: number;
94
+ sortBy?: KeysMatching<T, any>;
95
+ sortAsc?: boolean;
96
+ min?: Record<string, KeysMatching<T, number>>;
97
+ max?: Record<string, KeysMatching<T, number>>;
98
+ avg?: Record<string, KeysMatching<T, number>>;
99
+ groupBy?: KeysMatching<T, any> | KeysMatching<T, any>[];
100
+ count?: Record<string, string>;
101
+ }
102
+ export interface FindOpts<T = any> {
103
+ select?: KeysMatching<T, any>[];
104
+ exclude?: KeysMatching<T, any>[];
105
+ transform?: Function;
94
106
  }
95
107
  export interface VQuery_Control {
96
108
  }
@@ -124,27 +136,26 @@ export declare namespace VQueryT {
124
136
  type: "added" | "removed";
125
137
  }
126
138
  }
127
- export type QueryBase<T = Data> = VQueryT.QueryBase<T>;
128
- export type AddQuery<T = Data> = VQueryT.Add<T>;
129
- export type FindQuery<T = Data> = VQueryT.Find<T>;
130
- export type FindOneQuery<T = Data> = VQueryT.FindOne<T>;
131
- export type UpdateQuery<T = Data> = VQueryT.Update<T>;
132
- export type RemoveQuery<T = Data> = VQueryT.Remove<T>;
133
- export type UpdateOneOrAddQuery<T = Data> = VQueryT.UpdateOneOrAdd<T>;
134
- export type ToggleOneQuery<T = Data> = VQueryT.ToggleOne<T>;
135
- export type UpdateOneOrAddResult<T> = VQueryT.UpdateOneOrAddResult<T>;
136
- export type ToggleOneResult<T> = VQueryT.ToggleOneResult<T>;
137
- export interface DbFindOpts<T = any> {
138
- reverse?: boolean;
139
- limit?: number;
140
- offset?: number;
141
- sortBy?: KeysMatching<T, any>;
142
- sortAsc?: boolean;
139
+ export interface UpdateOneOrAdd<T> {
140
+ add_arg?: Arg<T>;
141
+ id_gen?: boolean;
142
+ context?: VContext;
143
143
  }
144
- export interface FindOpts<T = any> {
145
- select?: KeysMatching<T, any>[];
146
- exclude?: KeysMatching<T, any>[];
147
- transform?: Function;
144
+ export interface ValtheraCompatible {
145
+ c<T = Data>(collection: string): Collection<T>;
146
+ getCollections(): Promise<string[]>;
147
+ ensureCollection(collection: string): Promise<boolean>;
148
+ issetCollection(collection: string): Promise<boolean>;
149
+ add<T = Data>(query: VQueryT.Add<T>): Promise<T>;
150
+ find<T = Data>(query: VQueryT.Find<T>): Promise<T[]>;
151
+ findOne<T = Data>(query: VQueryT.FindOne<T>): Promise<T | null>;
152
+ update<T = Data>(query: VQueryT.Update<T>): Promise<T[]>;
153
+ updateOne<T = Data>(query: VQueryT.Update<T>): Promise<T | null>;
154
+ remove<T = Data>(query: VQueryT.Remove<T>): Promise<T[]>;
155
+ removeOne<T = Data>(query: VQueryT.Remove<T>): Promise<T | null>;
156
+ removeCollection(collection: string): Promise<boolean>;
157
+ updateOneOrAdd<T = Data>(query: VQueryT.UpdateOneOrAdd<T>): Promise<VQueryT.UpdateOneOrAddResult<T>>;
158
+ toggleOne<T = Data>(query: VQueryT.ToggleOne<T>): Promise<VQueryT.ToggleOneResult<T>>;
148
159
  }
149
160
  declare class Collection<D = Data> {
150
161
  db: ValtheraCompatible;
@@ -163,28 +174,6 @@ declare class Collection<D = Data> {
163
174
  updateOneOrAdd(search: Search<D>, updater: Updater<D>, { add_arg, context, id_gen }?: UpdateOneOrAdd<D>): Promise<VQueryT.UpdateOneOrAddResult<D>>;
164
175
  toggleOne(search: Search<D>, data?: Arg<D>, context?: VContext): Promise<VQueryT.ToggleOneResult<D>>;
165
176
  }
166
- export interface ValtheraCompatible {
167
- c<T = Data>(collection: string): Collection<T>;
168
- getCollections(): Promise<string[]>;
169
- ensureCollection(collection: string): Promise<boolean>;
170
- issetCollection(collection: string): Promise<boolean>;
171
- add<T = Data>(query: VQueryT.Add<T>): Promise<T>;
172
- find<T = Data>(query: VQueryT.Find<T>): Promise<T[]>;
173
- findOne<T = Data>(query: VQueryT.FindOne<T>): Promise<T | null>;
174
- update<T = Data>(query: VQueryT.Update<T>): Promise<T[]>;
175
- updateOne<T = Data>(query: VQueryT.Update<T>): Promise<T | null>;
176
- remove<T = Data>(query: VQueryT.Remove<T>): Promise<T[]>;
177
- removeOne<T = Data>(query: VQueryT.Remove<T>): Promise<T | null>;
178
- removeCollection(collection: string): Promise<boolean>;
179
- updateOneOrAdd<T = Data>(query: VQueryT.UpdateOneOrAdd<T>): Promise<VQueryT.UpdateOneOrAddResult<T>>;
180
- toggleOne<T = Data>(query: VQueryT.ToggleOne<T>): Promise<VQueryT.ToggleOneResult<T>>;
181
- }
182
- export interface VQuery_Control {
183
- dir?: {
184
- lastFileNum?: number;
185
- sortedFiles?: string[];
186
- };
187
- }
188
177
  declare namespace RelationTypes {
189
178
  type Path = [
190
179
  string,
@@ -218,7 +207,6 @@ export interface VQL_OP_Find<T = any> {
218
207
  collection: string;
219
208
  search?: Search<T>;
220
209
  limit?: number;
221
- fields?: VQL_Fields;
222
210
  select?: VQL_Fields;
223
211
  options?: DbFindOpts<T>;
224
212
  searchOpts?: FindOpts<T>;
@@ -226,7 +214,6 @@ export interface VQL_OP_Find<T = any> {
226
214
  export interface VQL_OP_FindOne<T = any> {
227
215
  collection: string;
228
216
  search: Search<T>;
229
- fields?: VQL_Fields;
230
217
  select?: VQL_Fields;
231
218
  searchOpts?: FindOpts<T>;
232
219
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/vql-client",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "VQL Client",