@@ -371,7 +371,7 @@ static mergeMetaWithStore(
371
371
372
372
` mergeMetaWithStore() ` is called during normalization when a processed entity is already found in the store.
373
373
374
- ### static queryKey(args, indexes, recurse, entities ): pk? {#queryKey}
374
+ ### static queryKey(args, queryKey, getEntity, getIndex ): pk? {#queryKey}
375
375
376
376
This method enables ` Entities ` to be [ Queryable] ( ./schema.md#queryable ) - allowing store access without an endpoint.
377
377
@@ -385,6 +385,31 @@ When used, expiry policy is computed based on the entity's own meta data.
385
385
386
386
By ** default** uses the first argument to lookup in [ pk()] ( #pk ) and [ indexes] ( #indexes )
387
387
388
+ #### getEntity(key, pk?)
389
+
390
+ Gets all entities of a type with one argument, or a single entity with two
391
+
392
+ ``` ts title="One argument"
393
+ const entitiesEntry = getEntity (this .schema .key );
394
+ if (entitiesEntry === undefined ) return INVALID ;
395
+ return Object .values (entitiesEntry ).map (
396
+ entity => entity && this .schema .pk (entity ),
397
+ );
398
+ ```
399
+
400
+ ``` ts title="Two arguments"
401
+ if (getEntity (this .key , id )) return id ;
402
+ ```
403
+
404
+ #### getIndex(key, indexName, value)
405
+
406
+ Returns the index entry (value->pk map)
407
+
408
+ ``` ts
409
+ const value = args [0 ][indexName ];
410
+ return getIndex (schema .key , indexName , value )[value ];
411
+ ```
412
+
388
413
### static createIfValid(processedEntity): Entity | undefined {#createIfValid}
389
414
390
415
Called when denormalizing an entity. This will create an instance of this class
0 commit comments