Merge pull request #2223 from no-heroes/fix/chaining-hooks
Fix: when chaining hooks, afterRead does not take previous doc but original doc
This commit is contained in:
@@ -233,7 +233,7 @@ async function find<T extends TypeWithID & Record<string, unknown>>(
|
||||
await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {
|
||||
await priorHook;
|
||||
|
||||
docRef = await hook({ req, query, doc, findMany: true }) || doc;
|
||||
docRef = await hook({ req, query, doc: docRef, findMany: true }) || doc;
|
||||
}, Promise.resolve());
|
||||
|
||||
return docRef;
|
||||
|
||||
Reference in New Issue
Block a user