(query: Query)
| 105 | } |
| 106 | |
| 107 | async getKeysByQuery(query: Query): Promise<PrimaryKey[]> { |
| 108 | const primaryKeyField = this.schema.collections[this.collection]!.primary; |
| 109 | const readQuery = cloneDeep(query); |
| 110 | readQuery.fields = [primaryKeyField]; |
| 111 | |
| 112 | // Allow unauthenticated access |
| 113 | const itemsService = new ItemsService(this.collection, { |
| 114 | knex: this.knex, |
| 115 | schema: this.schema, |
| 116 | }); |
| 117 | |
| 118 | // We read the IDs of the items based on the query, and then run `updateMany`. `updateMany` does it's own |
| 119 | // permissions check for the keys, so we don't have to make this an authenticated read |
| 120 | const items = await itemsService.readByQuery(readQuery); |
| 121 | return items.map((item: AnyItem) => item[primaryKeyField]).filter((pk) => pk); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Create a single new item. |
no test coverage detected