
ColumnBuilderPlan.prototype.addColumn( column as ColumnIdentifier ) as ColumnBuilderPlan
Create a new column definition for use with op.fromDocs . This method initializes the column with default properties unless overridden by additional chained methods. Default Behavior: If no other properties are set (such as xpath(), type(), or nullable()), the column defaults to:
./name (where name is the name passed to add-column()).stringtrue| Parameters | |
|---|---|
| column | The name of the column to be defined. This can be either a string or the return value from op.col. |
const op = require('/MarkLogic/optic');
op.fromDocs(
cts.collectionQuery("fromDocsJson"),
"/",
op.columnBuilder()
.addColumn("id").nullable(true).type("integer").default(-1)
.addColumn("name").collation("http://marklogic.com/collation/codepoint")
.addColumn("node").type("node").xpath(".")
.addColumn("expr").type("unsignedLong").expr(op.xdmp.random())
.addColumn("vector").type("vector").dimension(3)
.addColumn("geoData").xpath("geo").type("point").coordinateSystem("wgs84/double").units("miles"),
"myView", "myFragmentId"
)
.orderBy("id")
.select(["id","name","node","expr","vector","geoData","myFragmentId"])
.result()