* Get multiple items by primary keys. * * Uses `this.readByQuery` under the hood.
(keys: PrimaryKey[], query: Query = {}, opts?: QueryOptions)
| 633 | * Uses `this.readByQuery` under the hood. |
| 634 | */ |
| 635 | async readMany(keys: PrimaryKey[], query: Query = {}, opts?: QueryOptions): Promise<Item[]> { |
| 636 | const primaryKeyField = this.schema.collections[this.collection]!.primary; |
| 637 | validateKeys(this.schema, this.collection, primaryKeyField, keys); |
| 638 | |
| 639 | const filterWithKey = { _and: [{ [primaryKeyField]: { _in: keys } }, query.filter ?? {}] }; |
| 640 | const queryWithKey = assign({}, query, { filter: filterWithKey }); |
| 641 | |
| 642 | // Set query limit as the number of keys |
| 643 | if (Array.isArray(keys) && keys.length > 0 && !queryWithKey.limit) { |
| 644 | queryWithKey.limit = keys.length; |
| 645 | } |
| 646 | |
| 647 | return await this.readByQuery(queryWithKey, opts); |
| 648 | } |
| 649 | |
| 650 | /** |
| 651 | * Update multiple items by query. |
no test coverage detected