@nymphjs/nymph 1.0.0-alpha.8 → 1.0.0-beta.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +165 -0
  2. package/dist/Entity.d.ts +2 -2
  3. package/dist/Entity.js +56 -3
  4. package/dist/Entity.js.map +1 -1
  5. package/dist/Entity.test.js +1 -0
  6. package/dist/Entity.test.js.map +1 -1
  7. package/dist/Entity.types.d.ts +7 -7
  8. package/dist/Nymph.d.ts +6 -0
  9. package/dist/Nymph.js +17 -14
  10. package/dist/Nymph.js.map +1 -1
  11. package/dist/Nymph.types.d.ts +36 -36
  12. package/dist/driver/NymphDriver.d.ts +33 -6
  13. package/dist/driver/NymphDriver.js +36 -12
  14. package/dist/driver/NymphDriver.js.map +1 -1
  15. package/dist/driver/index.js +5 -1
  16. package/dist/driver/index.js.map +1 -1
  17. package/dist/driver/testArtifacts.js +49 -22
  18. package/dist/driver/testArtifacts.js.map +1 -1
  19. package/dist/errors/index.js +5 -1
  20. package/dist/errors/index.js.map +1 -1
  21. package/dist/index.d.ts +0 -2
  22. package/dist/index.js +6 -4
  23. package/dist/index.js.map +1 -1
  24. package/dist/nymphJoiProps.d.ts +4 -4
  25. package/dist/nymphJoiProps.js +2 -4
  26. package/dist/nymphJoiProps.js.map +1 -1
  27. package/dist/testArtifacts.d.ts +1 -1
  28. package/dist/testArtifacts.js +11 -11
  29. package/dist/testArtifacts.js.map +1 -1
  30. package/dist/testMocks.js +2 -2
  31. package/dist/testMocks.js.map +1 -1
  32. package/dist/utils.d.ts +2 -0
  33. package/dist/utils.js +48 -1
  34. package/dist/utils.js.map +1 -1
  35. package/jest.config.js +1 -1
  36. package/package.json +12 -16
  37. package/src/Entity.test.ts +2 -0
  38. package/src/Entity.ts +85 -5
  39. package/src/Nymph.ts +19 -8
  40. package/src/Nymph.types.ts +11 -11
  41. package/src/driver/NymphDriver.ts +90 -15
  42. package/src/driver/testArtifacts.ts +71 -22
  43. package/src/index.ts +0 -3
  44. package/src/nymphJoiProps.ts +4 -6
  45. package/src/testMocks.ts +3 -2
  46. package/src/utils.ts +59 -0
  47. package/dist/newGUID.d.ts +0 -1
  48. package/dist/newGUID.js +0 -14
  49. package/dist/newGUID.js.map +0 -1
  50. package/src/newGUID.ts +0 -11
package/src/Entity.ts CHANGED
@@ -132,11 +132,11 @@ export default class Entity<T extends EntityData = EntityData>
132
132
  /**
133
133
  * Whether this instance is a sleeping reference.
134
134
  */
135
- private $isASleepingReference = false;
135
+ protected $isASleepingReference = false;
136
136
  /**
137
137
  * The reference to use to wake.
138
138
  */
139
- private $sleepingReference: EntityReference | null = null;
139
+ protected $sleepingReference: EntityReference | null = null;
140
140
  /**
141
141
  * Properties that will not be serialized into JSON with toJSON(). This
142
142
  * can be considered a denylist, because these properties will not be set
@@ -208,7 +208,7 @@ export default class Entity<T extends EntityData = EntityData>
208
208
  has: (data: EntityData, name: string) => {
209
209
  this.$referenceWake();
210
210
 
211
- return data.hasOwnProperty(name) || this.$sdata.hasOwnProperty(name);
211
+ return name in data || name in this.$sdata;
212
212
  },
213
213
 
214
214
  get: (data: EntityData, name: string) => {
@@ -249,6 +249,42 @@ export default class Entity<T extends EntityData = EntityData>
249
249
  }
250
250
  return true;
251
251
  },
252
+
253
+ defineProperty: (
254
+ data: EntityData,
255
+ name: string,
256
+ descriptor: PropertyDescriptor
257
+ ) => {
258
+ this.$referenceWake();
259
+
260
+ if (this.$sdata.hasOwnProperty(name)) {
261
+ delete this.$sdata[name];
262
+ }
263
+ Object.defineProperty(data, name, descriptor);
264
+ return true;
265
+ },
266
+
267
+ getOwnPropertyDescriptor: (data: EntityData, name: string) => {
268
+ this.$referenceWake();
269
+
270
+ if (this.$sdata.hasOwnProperty(name)) {
271
+ data[name] = referencesToEntities(
272
+ JSON.parse(this.$sdata[name]),
273
+ this.$nymph,
274
+ this.$skipAc
275
+ );
276
+ delete this.$sdata[name];
277
+ }
278
+ return Object.getOwnPropertyDescriptor(data, name);
279
+ },
280
+
281
+ ownKeys: (data: EntityData) => {
282
+ this.$referenceWake();
283
+
284
+ return Object.getOwnPropertyNames(data).concat(
285
+ Object.getOwnPropertyNames(this.$sdata)
286
+ );
287
+ },
252
288
  };
253
289
  this.$dataStore = {} as T;
254
290
  this.$sdata = {};
@@ -332,6 +368,50 @@ export default class Entity<T extends EntityData = EntityData>
332
368
  getPrototypeOf: (entity: Entity) => {
333
369
  return entity.constructor.prototype;
334
370
  },
371
+
372
+ defineProperty: (
373
+ entity: Entity,
374
+ name: string,
375
+ descriptor: PropertyDescriptor
376
+ ) => {
377
+ if (
378
+ typeof name !== 'string' ||
379
+ name in entity ||
380
+ name.substring(0, 1) === '$'
381
+ ) {
382
+ if (name === 'tags' || name === 'cdate' || name === 'mdate') {
383
+ this.$referenceWake();
384
+ }
385
+ Object.defineProperty(entity, name, descriptor);
386
+ } else {
387
+ this.$referenceWake();
388
+ Object.defineProperty(entity.$data, name, descriptor);
389
+ }
390
+ return true;
391
+ },
392
+
393
+ getOwnPropertyDescriptor: (entity: Entity, name: string) => {
394
+ if (
395
+ typeof name !== 'string' ||
396
+ name in entity ||
397
+ name.substring(0, 1) === '$'
398
+ ) {
399
+ if (name === 'tags' || name === 'cdate' || name === 'mdate') {
400
+ this.$referenceWake();
401
+ }
402
+ return Object.getOwnPropertyDescriptor(entity, name);
403
+ } else {
404
+ this.$referenceWake();
405
+ return Object.getOwnPropertyDescriptor(entity.$data, name);
406
+ }
407
+ },
408
+
409
+ ownKeys: (entity: Entity) => {
410
+ this.$referenceWake();
411
+ return Object.getOwnPropertyNames(entity).concat(
412
+ Object.getOwnPropertyNames(entity.$data)
413
+ );
414
+ },
335
415
  }) as Entity<T>;
336
416
  }
337
417
 
@@ -453,7 +533,7 @@ export default class Entity<T extends EntityData = EntityData>
453
533
  if (includeSData) {
454
534
  // Access all the serialized properties to initialize them.
455
535
  for (const key in this.$sdata) {
456
- const unused: any = (this as any)[key];
536
+ const _unused: any = (this as any)[key];
457
537
  }
458
538
  }
459
539
  return entitiesToReferences({ ...this.$dataStore });
@@ -487,7 +567,7 @@ export default class Entity<T extends EntityData = EntityData>
487
567
 
488
568
  // Access all the serialized properties to initialize them.
489
569
  for (const key in this.$sdata) {
490
- const unused: any = (this as any)[key];
570
+ const _unused: any = (this as any)[key];
491
571
  }
492
572
  return {
493
573
  guid: this.guid,
package/src/Nymph.ts CHANGED
@@ -416,7 +416,8 @@ export default class Nymph {
416
416
  * Therefore, offset will be from the newest entity.
417
417
  * - sort - How to sort the entities. Accepts "cdate" or "mdate". Defaults to
418
418
  * "cdate".
419
- * - return - What to return. "entity" or "guid". Defaults to "entity".
419
+ * - return - What to return. "entity", "guid", or "count". Defaults to
420
+ * "entity".
420
421
  * - source - Will be 'client' if the query came from a REST call.
421
422
  * - skipCache - If true, Nymph will skip the cache and retrieve the entity
422
423
  * from the DB.
@@ -559,10 +560,13 @@ export default class Nymph {
559
560
  *
560
561
  * @param options The options.
561
562
  * @param selectors Unlimited optional selectors to search for. If none are given, all entities are retrieved for the given options.
562
- * @returns An array of entities.
563
- * @todo An option to place a total count in a var.
563
+ * @returns An array of entities or guids, or a count.
564
564
  * @todo Use an asterisk to specify any variable.
565
565
  */
566
+ public async getEntities<T extends EntityConstructor = EntityConstructor>(
567
+ options: Options<T> & { return: 'count' },
568
+ ...selectors: Selector[]
569
+ ): Promise<number>;
566
570
  public async getEntities<T extends EntityConstructor = EntityConstructor>(
567
571
  options: Options<T> & { return: 'guid' },
568
572
  ...selectors: Selector[]
@@ -574,7 +578,7 @@ export default class Nymph {
574
578
  public async getEntities<T extends EntityConstructor = EntityConstructor>(
575
579
  options: Options<T> = {},
576
580
  ...selectors: Selector[]
577
- ): Promise<ReturnType<T['factorySync']>[] | string[]> {
581
+ ): Promise<ReturnType<T['factorySync']>[] | string[] | number> {
578
582
  for (let callback of this.beforeGetEntitiesCallbacks) {
579
583
  if (callback) {
580
584
  callback(this, options, selectors);
@@ -594,8 +598,12 @@ export default class Nymph {
594
598
  *
595
599
  * @param options The options.
596
600
  * @param selectors Unlimited optional selectors to search for, or a single GUID. If none are given, all entities are searched for the given options.
597
- * @returns An entity, or null on failure or nothing found.
601
+ * @returns An entity or guid, or null on failure or nothing found, or a number.
598
602
  */
603
+ public async getEntity<T extends EntityConstructor = EntityConstructor>(
604
+ options: Options<T> & { return: 'count' },
605
+ ...selectors: Selector[]
606
+ ): Promise<number>;
599
607
  public async getEntity<T extends EntityConstructor = EntityConstructor>(
600
608
  options: Options<T> & { return: 'guid' },
601
609
  ...selectors: Selector[]
@@ -615,7 +623,7 @@ export default class Nymph {
615
623
  public async getEntity<T extends EntityConstructor = EntityConstructor>(
616
624
  options: Options<T> = {},
617
625
  ...selectors: Selector[] | string[]
618
- ): Promise<ReturnType<T['factorySync']> | string | null> {
626
+ ): Promise<ReturnType<T['factorySync']> | string | number | null> {
619
627
  // Set up options and selectors.
620
628
  if (typeof selectors[0] === 'string') {
621
629
  selectors = [{ type: '&', guid: selectors[0] }];
@@ -630,6 +638,9 @@ export default class Nymph {
630
638
  options,
631
639
  ...(selectors as Selector[])
632
640
  );
641
+ if (options.return === 'count') {
642
+ return entities as unknown as number;
643
+ }
633
644
  if (!entities || !entities.length) {
634
645
  return null;
635
646
  }
@@ -822,7 +833,7 @@ export default class Nymph {
822
833
  : T extends 'afterDeleteUID'
823
834
  ? 'afterDeleteUIDCallbacks'
824
835
  : never;
825
- if (!this.hasOwnProperty(prop)) {
836
+ if (!(prop in this)) {
826
837
  throw new Error('Invalid event type.');
827
838
  }
828
839
  // @ts-ignore: The callback should be the right type here.
@@ -911,7 +922,7 @@ export default class Nymph {
911
922
  : T extends 'afterDeleteUID'
912
923
  ? 'afterDeleteUIDCallbacks'
913
924
  : never;
914
- if (!this.hasOwnProperty(prop)) {
925
+ if (!(prop in this)) {
915
926
  return false;
916
927
  }
917
928
  // @ts-ignore: The callback should always be the right type here.
@@ -105,13 +105,13 @@ export type Options<T extends EntityConstructor = EntityConstructor> = {
105
105
  offset?: number;
106
106
  reverse?: boolean;
107
107
  sort?: 'cdate' | 'mdate';
108
- return?: 'entity' | 'guid';
108
+ return?: 'entity' | 'guid' | 'count';
109
109
  source?: string;
110
110
  skipCache?: boolean;
111
111
  skipAc?: boolean;
112
112
  };
113
113
 
114
- export type Clause<C> = C | C[];
114
+ export type Clause<C> = C | Exclude<C, undefined>[];
115
115
 
116
116
  export type OrWithTime<T> = T | [string, null, string];
117
117
 
@@ -226,17 +226,17 @@ export type Selector = {
226
226
  export type FormattedSelector = {
227
227
  type: '&' | '|' | '!&' | '!|';
228
228
 
229
- guid?: PrimitiveSelector['guid'][];
230
- '!guid'?: PrimitiveSelector['guid'][];
229
+ guid?: PrimitiveSelector['guid'][][];
230
+ '!guid'?: PrimitiveSelector['guid'][][];
231
231
 
232
- tag?: PrimitiveSelector['tag'][];
233
- '!tag'?: PrimitiveSelector['tag'][];
232
+ tag?: PrimitiveSelector['tag'][][];
233
+ '!tag'?: PrimitiveSelector['tag'][][];
234
234
 
235
- defined?: PrimitiveSelector['defined'][];
236
- '!defined'?: PrimitiveSelector['defined'][];
235
+ defined?: PrimitiveSelector['defined'][][];
236
+ '!defined'?: PrimitiveSelector['defined'][][];
237
237
 
238
- truthy?: PrimitiveSelector['truthy'][];
239
- '!truthy'?: PrimitiveSelector['truthy'][];
238
+ truthy?: PrimitiveSelector['truthy'][][];
239
+ '!truthy'?: PrimitiveSelector['truthy'][][];
240
240
 
241
241
  equal?: PrimitiveSelector['equal'][];
242
242
  '!equal'?: PrimitiveSelector['equal'][];
@@ -295,7 +295,7 @@ export interface TilmeldInterface {
295
295
  gatekeeper(ability?: string): boolean;
296
296
  authenticate(): void;
297
297
  clearSession(): void;
298
- extractToken(token: string): any;
298
+ extractToken(token: string): Promise<any>;
299
299
  fillSession(user: any): void;
300
300
  checkClientUIDPermissions(name: string, type?: TilmeldAccessLevels): boolean;
301
301
  }
@@ -2,13 +2,14 @@ import fs from 'fs';
2
2
  import { difference } from 'lodash';
3
3
  import ReadLines from 'n-readlines';
4
4
  import strtotime from 'locutus/php/datetime/strtotime';
5
+ import { guid } from '@nymphjs/guid';
5
6
 
6
7
  import type Nymph from '../Nymph';
7
- import newGUID from '../newGUID';
8
8
  import {
9
9
  EntityConstructor,
10
10
  EntityData,
11
11
  EntityInterface,
12
+ EntityReference,
12
13
  SerializedEntityData,
13
14
  } from '../Entity.types';
14
15
  import { InvalidParametersError, UnableToConnectError } from '../errors';
@@ -69,6 +70,10 @@ export default abstract class NymphDriver {
69
70
  protected abstract exportEntities(
70
71
  writeLine: (line: string) => void
71
72
  ): Promise<void>;
73
+ abstract getEntities<T extends EntityConstructor = EntityConstructor>(
74
+ options: Options<T> & { return: 'count' },
75
+ ...selectors: Selector[]
76
+ ): Promise<number>;
72
77
  abstract getEntities<T extends EntityConstructor = EntityConstructor>(
73
78
  options: Options<T> & { return: 'guid' },
74
79
  ...selectors: Selector[]
@@ -80,7 +85,13 @@ export default abstract class NymphDriver {
80
85
  abstract getEntities<T extends EntityConstructor = EntityConstructor>(
81
86
  options?: Options<T>,
82
87
  ...selectors: Selector[]
83
- ): Promise<ReturnType<T['factorySync']>[] | string[]>;
88
+ ): Promise<ReturnType<T['factorySync']>[] | string[] | number>;
89
+ protected abstract getEntitiesSync<
90
+ T extends EntityConstructor = EntityConstructor
91
+ >(
92
+ options: Options<T> & { return: 'count' },
93
+ ...selectors: Selector[]
94
+ ): number;
84
95
  protected abstract getEntitiesSync<
85
96
  T extends EntityConstructor = EntityConstructor
86
97
  >(
@@ -98,7 +109,7 @@ export default abstract class NymphDriver {
98
109
  >(
99
110
  options?: Options<T>,
100
111
  ...selectors: Selector[]
101
- ): ReturnType<T['factorySync']>[] | string[];
112
+ ): ReturnType<T['factorySync']>[] | string[] | number;
102
113
  abstract getUID(name: string): Promise<number | null>;
103
114
  abstract import(filename: string): Promise<boolean>;
104
115
  abstract newUID(name: string): Promise<number | null>;
@@ -516,16 +527,26 @@ export default abstract class NymphDriver {
516
527
  */
517
528
  protected entityReferenceSearch(
518
529
  value: any,
519
- entity: EntityInterface | string | (EntityInterface | string)[]
530
+ entity:
531
+ | EntityInterface
532
+ | EntityReference
533
+ | string
534
+ | (EntityInterface | EntityReference | string)[]
520
535
  ) {
521
536
  // Get the GUID, if the passed $entity is an object.
522
537
  const guids: string[] = [];
523
538
  if (Array.isArray(entity)) {
524
- for (const curEntity of entity) {
525
- if (typeof curEntity === 'string') {
526
- guids.push(curEntity);
527
- } else if (typeof curEntity.guid === 'string') {
528
- guids.push(curEntity.guid);
539
+ if (entity[0] === 'nymph_entity_reference') {
540
+ guids.push(value[1]);
541
+ } else {
542
+ for (const curEntity of entity) {
543
+ if (typeof curEntity === 'string') {
544
+ guids.push(curEntity);
545
+ } else if (Array.isArray(curEntity)) {
546
+ guids.push(curEntity[1]);
547
+ } else if (typeof curEntity.guid === 'string') {
548
+ guids.push(curEntity.guid);
549
+ }
529
550
  }
530
551
  }
531
552
  } else if (typeof entity === 'string') {
@@ -684,6 +705,10 @@ export default abstract class NymphDriver {
684
705
  * @param selectors Unlimited optional selectors to search for, or a single GUID. If none are given, all entities are searched for the given options.
685
706
  * @returns An entity, or null on failure or nothing found.
686
707
  */
708
+ public getEntitySync<T extends EntityConstructor = EntityConstructor>(
709
+ options: Options<T> & { return: 'count' },
710
+ ...selectors: Selector[]
711
+ ): number;
687
712
  public getEntitySync<T extends EntityConstructor = EntityConstructor>(
688
713
  options: Options<T> & { return: 'guid' },
689
714
  ...selectors: Selector[]
@@ -692,6 +717,10 @@ export default abstract class NymphDriver {
692
717
  options: Options<T>,
693
718
  ...selectors: Selector[]
694
719
  ): ReturnType<T['factorySync']> | null;
720
+ public getEntitySync<T extends EntityConstructor = EntityConstructor>(
721
+ options: Options<T> & { return: 'count' },
722
+ guid: string
723
+ ): number;
695
724
  public getEntitySync<T extends EntityConstructor = EntityConstructor>(
696
725
  options: Options<T> & { return: 'guid' },
697
726
  guid: string
@@ -703,7 +732,7 @@ export default abstract class NymphDriver {
703
732
  public getEntitySync<T extends EntityConstructor = EntityConstructor>(
704
733
  options: Options<T> = {},
705
734
  ...selectors: Selector[] | string[]
706
- ): ReturnType<T['factorySync']> | string | null {
735
+ ): ReturnType<T['factorySync']> | string | number | null {
707
736
  // Set up options and selectors.
708
737
  if (typeof selectors[0] === 'string') {
709
738
  selectors = [{ type: '&', guid: selectors[0] }];
@@ -713,12 +742,39 @@ export default abstract class NymphDriver {
713
742
  options,
714
743
  ...(selectors as Selector[])
715
744
  );
745
+ if (options.return === 'count') {
746
+ return entities as unknown as number;
747
+ }
716
748
  if (!entities || !entities.length) {
717
749
  return null;
718
750
  }
719
751
  return entities[0];
720
752
  }
721
753
 
754
+ protected getEntitesRowLike<T extends EntityConstructor = EntityConstructor>(
755
+ options: Options<T> & { return: 'count' },
756
+ selectors: Selector[],
757
+ performQueryCallback: (
758
+ options: Options<T>,
759
+ formattedSelectors: FormattedSelector[],
760
+ etype: string
761
+ ) => {
762
+ result: any;
763
+ },
764
+ rowFetchCallback: () => any,
765
+ freeResultCallback: () => void,
766
+ getCountCallback: (row: any) => number,
767
+ getGUIDCallback: (row: any) => string,
768
+ getTagsAndDatesCallback: (row: any) => {
769
+ tags: string[];
770
+ cdate: number;
771
+ mdate: number;
772
+ },
773
+ getDataNameAndSValueCallback: (row: any) => {
774
+ name: string;
775
+ svalue: string;
776
+ }
777
+ ): { result: any; process: () => number };
722
778
  protected getEntitesRowLike<T extends EntityConstructor = EntityConstructor>(
723
779
  options: Options<T> & { return: 'guid' },
724
780
  selectors: Selector[],
@@ -731,6 +787,7 @@ export default abstract class NymphDriver {
731
787
  },
732
788
  rowFetchCallback: () => any,
733
789
  freeResultCallback: () => void,
790
+ getCountCallback: (row: any) => number,
734
791
  getGUIDCallback: (row: any) => string,
735
792
  getTagsAndDatesCallback: (row: any) => {
736
793
  tags: string[];
@@ -754,6 +811,7 @@ export default abstract class NymphDriver {
754
811
  },
755
812
  rowFetchCallback: () => any,
756
813
  freeResultCallback: () => void,
814
+ getCountCallback: (row: any) => number,
757
815
  getGUIDCallback: (row: any) => string,
758
816
  getTagsAndDatesCallback: (row: any) => {
759
817
  tags: string[];
@@ -777,6 +835,7 @@ export default abstract class NymphDriver {
777
835
  },
778
836
  rowFetchCallback: () => any,
779
837
  freeResultCallback: () => void,
838
+ getCountCallback: (row: any) => number,
780
839
  getGUIDCallback: (row: any) => string,
781
840
  getTagsAndDatesCallback: (row: any) => {
782
841
  tags: string[];
@@ -787,7 +846,10 @@ export default abstract class NymphDriver {
787
846
  name: string;
788
847
  svalue: string;
789
848
  }
790
- ): { result: any; process: () => ReturnType<T['factorySync']>[] | string[] } {
849
+ ): {
850
+ result: any;
851
+ process: () => ReturnType<T['factorySync']>[] | string[] | number;
852
+ } {
791
853
  if (!this.isConnected()) {
792
854
  throw new UnableToConnectError('not connected to DB');
793
855
  }
@@ -805,6 +867,7 @@ export default abstract class NymphDriver {
805
867
  }
806
868
 
807
869
  let entities: ReturnType<T['factorySync']>[] | string[] = [];
870
+ let count = 0;
808
871
  const EntityClass =
809
872
  options.class ?? (this.nymph.getEntityClass('Entity') as T);
810
873
  const etype = EntityClass.ETYPE;
@@ -842,7 +905,14 @@ export default abstract class NymphDriver {
842
905
  const guid = entity.guid;
843
906
  return {
844
907
  result: Promise.resolve(null),
845
- process: () => (options.return === 'guid' ? [guid] : [entity]),
908
+ process: () =>
909
+ options.return === 'count'
910
+ ? guid
911
+ ? 1
912
+ : 0
913
+ : options.return === 'guid'
914
+ ? [guid]
915
+ : [entity],
846
916
  };
847
917
  }
848
918
  }
@@ -856,7 +926,12 @@ export default abstract class NymphDriver {
856
926
  result,
857
927
  process: () => {
858
928
  let row = rowFetchCallback();
859
- if (options.return === 'guid') {
929
+ if (options.return === 'count') {
930
+ while (row != null) {
931
+ count += getCountCallback(row);
932
+ row = rowFetchCallback();
933
+ }
934
+ } else if (options.return === 'guid') {
860
935
  while (row != null) {
861
936
  (entities as string[]).push(getGUIDCallback(row));
862
937
  row = rowFetchCallback();
@@ -912,7 +987,7 @@ export default abstract class NymphDriver {
912
987
 
913
988
  freeResultCallback();
914
989
 
915
- return entities;
990
+ return options.return === 'count' ? count : entities;
916
991
  },
917
992
  };
918
993
  }
@@ -955,7 +1030,7 @@ export default abstract class NymphDriver {
955
1030
  let success = false;
956
1031
  if (entity.guid == null) {
957
1032
  const cdate = mdate;
958
- const newId = newGUID();
1033
+ const newId = guid();
959
1034
  success = await saveNewEntityCallback(
960
1035
  entity,
961
1036
  newId,