mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Add items.read filter hook (#10284)
* Add items.read filter hook * Fix issue cause by query being wrongly modified Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -292,6 +292,7 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
|
||||
`${this.eventScope}.read`,
|
||||
records,
|
||||
{
|
||||
query,
|
||||
collection: this.collection,
|
||||
},
|
||||
{
|
||||
@@ -325,7 +326,7 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
|
||||
const primaryKeyField = this.schema.collections[this.collection].primary;
|
||||
|
||||
const filterWithKey = assign({}, query.filter, { [primaryKeyField]: { _eq: key } });
|
||||
const queryWithKey = assign(query, { filter: filterWithKey });
|
||||
const queryWithKey = assign({}, query, { filter: filterWithKey });
|
||||
|
||||
const results = await this.readByQuery(queryWithKey, opts);
|
||||
|
||||
@@ -343,7 +344,7 @@ export class ItemsService<Item extends AnyItem = AnyItem> implements AbstractSer
|
||||
const primaryKeyField = this.schema.collections[this.collection].primary;
|
||||
|
||||
const filterWithKey = { _and: [{ [primaryKeyField]: { _in: keys } }, query.filter ?? {}] };
|
||||
const queryWithKey = assign(query, { filter: filterWithKey });
|
||||
const queryWithKey = assign({}, query, { filter: filterWithKey });
|
||||
|
||||
const results = await this.readByQuery(queryWithKey, opts);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user