Function query

  • Parameters

    • universe: Contract

      composite contract

    • layout: { [key: string]: any }

      an object describing the query using a set of cardinality operators

    • skeleton: object

      contract skeleton for the returned contexts

    Returns IterableIterator<Contract>

    an iterable over the valid contexts

    module:contrato

    module:contrato.query

    This method will generate a set of contexts that consist of every possible valid combination that matches the blueprint layout. It uses depth first search to calculate the product of contract combinations and returns the results as an iterable. This allows to reduce the memory usage when dealing with a large universe of contracts.

    import {query, Contract} from 'contrato';

    const contract = new Contract({ ... })
    contract.addChildren([ ... ])

    const contexts = query(contract, {
    'hw.device-type': 1,
    'arch.sw': {
    cardinality: 1,
    filter: { type: 'object', properties: { slug: { const: 'armv7hf' } } },
    },
    });

    for (const context of contexts) {
    console.log(context.toJSON());
    }