Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagegroovy
def qapi = api.queryApi()

def p = qapi.tables().products()

return qapi.source(p, [p.sku(), p.label], p.sku().equal("MB-0001"))
        .stream { it.collect { it } }

Line 1: the QueryAPI reference is stored in q qapi variable for later use.

Line 3: the reference to product master table is stored in q p variable.

Line 5: the source() method says to query table tLine 5-8: products table with a filter expression that defines which rows to return in the result

Line 86: QueryAPI provides the result always as a stream (ResultStream interface). So it is up to you how you will consume each individual row. In our example, all rows are collected to a List.

...