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:
James Mikrut
2023-03-06 11:27:25 -05:00
committed by GitHub
4 changed files with 62 additions and 1 deletions

View File

@@ -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;