Loading TOC...

temporal.collectionCreate

temporal.collectionCreate(
   collection-name as String,
   system-axis as String,
   [valid-axis as String?],
   [options as String[]]
) as (Number|String)

Summary

This function constructs a named and protected temporal collection in the schema database with the specified system and optional valid axes. This function assumes that the axes already exist. The temporal collection is stored in the Schemas database.

A TEMPORAL-DUPCOLLECTION exception is thrown if the collection already exists.

For details on how to create a collection, see Create a Temporal Collection in the Temporal Developer's Guide

Parameters
collection-name The name to be used to identify the temporal collection.
system-axis The name of the axis to be used by the collection as the system axis.
valid-axis The name of the axis to be used by the collection as the valid axis. This axis is only used by bi-temporal documents and is not specified for uni-temporal documents.
options Options to control access to the temporal collection:
updates-admin-override
Specifies that users with the admin role can change or delete temporal documents using non-temporal functions, such as xdmp:document-insert and xdmp:document-delete.
archive-default-dir=dir
When archive-default-dir is specified to be a non-empty value and when you specify to protect a document with a relative archive path, the archive file path is the concatenation of this value, / and the relative path.
document-protect-priv=priv_URI
Specifies the privilege required to call the temporal:documentProtect function. By default, temporal:documentProtect requires the http://marklogic.com/xdmp/privileges/temporal-document-protect privilege. An empty value means that no user except admin is allowed to call temporal:documentProtect.
document-wipe-priv=priv_URI
Specifies the privilege required to call the temporal:documentWipe function. By default, temporal:documentWipe requires the http://marklogic.com/xdmp/privileges/temporal-document-protect privilege. An empty value means that no user except admin is allowed to call temporal:documentWipe.
override-priv=priv_URI
Specifies the privilege required to perform admin-override operations. By default, only users with the admin role are allowed for these operations and only when updates-admin-override option is specified.
allow-nonempty
When specified, no exception is thrown when documents tagged with the collection URI exists.

Example

const temporal = require("/MarkLogic/temporal.xqy");

temporal.collectionCreate("temporalCollection", "system", "valid");

// Creates a temporal collection, named "temporalCollection", with the 
// "system" and "valid" axes. Use temporal.axisCreate to create the 
// "system" and "valid" axes.  Returns the ID of the temporal collection.

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