Loading TOC...

MarkLogic 12 EA 2 Product Documentation
op.fromLiterals

op.fromLiterals(
   rowdefs as String,
   [qualifier as String]
) as AccessPlan

Summary

Constructs a literal row set as in the SQL VALUES or SPARQL VALUES statements. When specifying rows with arrays, values are mapped to column names by position.

Parameters
rowdefs This parameter is either an array of object literals or sem.binding objects in which the key is a column name string identifying the column and the value is a literal with the value of the column, or this parameter is an object with a columnNames key having a value of an array of column names and a rowValues key having a value of an array of arrays with literal values.
qualifier Specifies a name for qualifying the column names in place of the combination of the schema and view names. Use cases for the qualifier include self joins. Using an empty string removes all qualification from the column names.

Usage Notes

The fromLiterals function is one of the Data Access Functions.

Example

// Build a table with five rows and return the average values for
// group 1 and group 2.

const op = require('/MarkLogic/optic');
op.fromLiterals([
            {group:1, val:2},
            {group:1, val:4},
            {group:2, val:3},
            {group:2, val:5},
            {group:2, val:7}
            ])
          .groupBy('group', op.avg('valAvg', 'val'))
          .orderBy('group')
          .result()
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.