(docs: T[])
| 479 | types = Object.keys(nedbBucket) as AllTypes[]; |
| 480 | } |
| 481 | async function next(docs: T[]): Promise<T[]> { |
| 482 | const foundDocs: T[] = []; |
| 483 | |
| 484 | for (const d of docs) { |
| 485 | for (const type of types) { |
| 486 | // If the doc is null, we want to search for parentId === null |
| 487 | const parent = await database.findOne<T>(type, { _id: d.parentId }); |
| 488 | parent && foundDocs.push(parent); |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | if (foundDocs.length === 0) { |
| 493 | return docsToReturn; |
| 494 | } |
| 495 | |
| 496 | // Continue searching for children |
| 497 | docsToReturn = [...docsToReturn, ...foundDocs]; |
| 498 | return next(foundDocs); |
| 499 | } |
| 500 | |
| 501 | return next([doc]); |
| 502 | }, |
no test coverage detected