@vroskus/library-datahandler 1.0.40 → 1.0.41

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/index.d.ts CHANGED
@@ -56,7 +56,9 @@ declare class DatabaseService<C extends $Config, MC extends {
56
56
  }): Promise<MC['Models'][MN]>;
57
57
  updateOne<MN extends keyof MC['Config']>(request: {
58
58
  modelName: MN;
59
- params: MC['Config'][MN]['ModelUpdateParams'] | MC['Models'][MN];
59
+ params: (MC['Config'][MN]['ModelUpdateParams'] | MC['Models'][MN]) & {
60
+ id: string;
61
+ };
60
62
  }): Promise<MC['Models'][MN]>;
61
63
  toggleOne<MN extends keyof MC['Config']>(request: {
62
64
  modelName: MN;
package/dist/index.js CHANGED
@@ -280,12 +280,12 @@ class DatabaseService {
280
280
  id,
281
281
  modelName,
282
282
  });
283
- const attributes = lodash_1.default.omit(params, [
284
- 'id',
285
- 'createdAt',
286
- 'updatedAt',
287
- ]);
288
283
  if (typeof modelInstance.update === 'function') {
284
+ const attributes = lodash_1.default.omit(params, [
285
+ 'id',
286
+ 'createdAt',
287
+ 'updatedAt',
288
+ ]);
289
289
  yield modelInstance.update(attributes);
290
290
  }
291
291
  return modelInstance;
@@ -298,11 +298,6 @@ class DatabaseService {
298
298
  request,
299
299
  });
300
300
  const { modelName, where, } = request;
301
- const attributes = lodash_1.default.omit(where, [
302
- 'id',
303
- 'createdAt',
304
- 'updatedAt',
305
- ]);
306
301
  const model = __classPrivateFieldGet(this, _DatabaseService_instances, "m", _DatabaseService_getModel).call(this, {
307
302
  modelName,
308
303
  });
@@ -316,6 +311,11 @@ class DatabaseService {
316
311
  yield modelInstance.destroy();
317
312
  }
318
313
  else {
314
+ const attributes = lodash_1.default.omit(where, [
315
+ 'id',
316
+ 'createdAt',
317
+ 'updatedAt',
318
+ ]);
319
319
  modelInstance = yield model.create(attributes);
320
320
  }
321
321
  return modelInstance;
package/dist/types.d.ts CHANGED
@@ -37,6 +37,6 @@ export type $RequestContext = {
37
37
  request: Record<string, any>;
38
38
  };
39
39
  export type $Where<MCC extends Record<MN, any>, MN extends keyof MCC> = MCC[MN]['ModelQueryParams'] & {
40
- [key: string]: boolean | number | Record<string, unknown> | string | void;
40
+ [key: string]: boolean | null | number | Record<string, unknown> | string;
41
41
  };
42
42
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vroskus/library-datahandler",
3
- "version": "1.0.40",
3
+ "version": "1.0.41",
4
4
  "description": "Data Handler",
5
5
  "author": "Vilius Roškus <vilius@regattas.eu>",
6
6
  "license": "MIT",