Find: (<N>(collectionName, ids, document) => Process<(Resources.Resource<N> | undefined)[]>)

Type declaration

    • <N>(collectionName, ids, document): Process<(Resources.Resource<N> | undefined)[]>
    • resources.find

      Retrieves full or partial representations of all resources in a list of given IDs. Parameter document is a GraphQL DocumentNode that defines a fragment on the resource object type, to control which fields are returned.

      The resulting array will always have the same length as the provided IDs, with each result corresponding to the ID at the same index. Unknown IDs will have null entries in the resulting array.

      Note: This function returns a generator. For async behavior, use with a [[Meta.Process.ProcessorRunner | ProcessorRunner]] such as that returned by [[Run.forDb]] or [[Project.run]].

      Type Parameters

      Parameters

      • collectionName: N
      • ids: (string | undefined)[]
      • document: graphql.DocumentNode

      Returns Process<(Resources.Resource<N> | undefined)[]>

      Example

      import gql from "graphql-tag";
      import { connect, Process } from "@truffle/db";

      const db = connect({
      // ...
      });

      const { Run, resources } = Process;

      const { run } = Run.forDb(db);

      const sources: (
      | Pick<Resources.Resource<"sources">, "contents">
      | null
      )[] = await run(resources.find, "sources", ["0x...", "0x..."], gql`
      fragment Contents on Source {
      contents
      }
      `);

Generated using TypeDoc