Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 552 Bytes

parallel-sources.md

File metadata and controls

25 lines (20 loc) · 552 Bytes

Parallel sources

You can read source results in parallel simply defining sources in an array:

const booksWithAuthors = new Selector(
  [
    booksCollection,
    authorsCollection
  ],
  booksAndAuthors => {
    const books = booksAndAuthors[0];
    const authors = booksAndAuthors[1];
    return booksResults.map(book => ({
      ...book,
      authorName: authorsResults.find(author => author.id === book.author)
    }))
  }
);

// Now books and authors fetchs are executed in parallel
const results = await booksWithAuthors.read();