Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Batch

Index

Type aliases

Batch

Batch: { breadcrumb: any; entry?: any; input: any; output: any; result?: any; structure: any }

Type declaration

  • breadcrumb: any
  • Optional entry?: any
  • input: any
  • output: any
  • Optional result?: any
  • structure: any

Configure

Configure<C>: <B>(options: Options<B>) => <I, O>(inputs: Inputs<B, I>) => Process<C, Outputs<B, O>>

Type parameters

Type declaration

Input

Input<B>: B["input"]

Type parameters

Inputs

Inputs<B, I>: $<Structure<B>, [I]>

Type parameters

Options

Options<B, I, O>: { convert: any; extract: any; find: any; initialize: any; iterate: any; merge: any; process: any }

Describes a batch process for querying and/or mutating resources

Type parameters

Type declaration

  • convert: function
    • convert(options: { input: I; inputs: Inputs<B, I>; result: Result<B> }): O
  • extract: function
    • extract(options: { breadcrumb: Breadcrumb<B>; input: I; inputs: Inputs<B, I> }): Entry<B>
  • find: function
    • find(options: { breadcrumb: Breadcrumb<B>; inputs: Inputs<B, I> }): I
  • initialize: function
    • initialize(options: { inputs: Inputs<B, I> }): $<Structure<B>, [O]>
  • iterate: function
    • iterate(options: { inputs: Inputs<B, I> }): Iterable<{ breadcrumb: Breadcrumb<B>; input: I }>
    • Describes how to traverse the particular Inputs structure to produce an Iterable of each Input along with a breadcrumb to describe how to place that input in the parent structure.

      Parameters

      Returns Iterable<{ breadcrumb: Breadcrumb<B>; input: I }>

  • merge: function
    • merge(options: { breadcrumb: Breadcrumb<B>; output: O; outputs: Outputs<B, O> }): $<Structure<B>, [O]>
  • process: function
    • process(options: { entries: Entries<B>; inputs: Inputs<B, I> }): Generator<Web3Request | GraphQlRequest, Results<B>, any>

Output

Output<B>: B["output"]

Type parameters

Outputs

Outputs<B, O>: $<Structure<B>, [O]>

Type parameters

Functions

Const configure

  • configure<B>(options: Options<B, Input<B>, Output<B>>): <I, O>(inputs: $<Structure<B>, [I]>) => Generator<Web3Request | GraphQlRequest, $<Structure<B>, [O]>, any>
  • Configure a batch process to query and/or mutate resources.

    Batch processes take structured inputs, split those up and extract a list of entries that can be passed to some process. Given the results of that process, each result is then converted back to some output form and arranged into the same given structure as outputs.

    This abstraction makes it easier to build bulk iteractions with @truffle/db, rather than, say, submitting multiple separate add mutations.

    For instance, Truffle artifacts each contain two bytecodes - to minimize the number of bytecodesAdd queries, one might want to convert each input artifact to a flat list of bytecodes, execute a single mutation request to

    truffle/db,

    and then automatically pair the resulting bytecode IDs with the respective artifact bytecodes.

    The process is roughly as follows:

    ,--------. iterate() ,----------. extract() ,---------. | Inputs | --> | Input... | --> | Entry[] | --------' ----------' `---------'

      |                                            |
      |  initialize()                              |  process()
      V                                            V
    

    ,---------. merge() ,----------. convert() ,----------. | Outputs | <-- | Output[] | <-- | Result[] | ---------' ----------' `----------'

    Type parameters

    Parameters

    Returns <I, O>(inputs: $<Structure<B>, [I]>) => Generator<Web3Request | GraphQlRequest, $<Structure<B>, [O]>, any>

      • <I, O>(inputs: $<Structure<B>, [I]>): Generator<Web3Request | GraphQlRequest, $<Structure<B>, [O]>, any>
      • Type parameters

        • I: any

        • O: any

        Parameters

        • inputs: $<Structure<B>, [I]>

        Returns Generator<Web3Request | GraphQlRequest, $<Structure<B>, [O]>, any>

Generated using TypeDoc