Loading TOC...

MarkLogic Server 11.0 Product Documentation
temporal:collection-create

temporal:collection-create(
   $collection-name as xs:string,
   $system-axis as xs:string,
   [$valid-axis as xs:string?],
   [$options as xs:string*]
) as xs:unsignedLong

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:document-protect function. By default, temporal:document-protect 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:document-protect .
document-wipe-priv=priv_URI
Specifies the privilege required to call the temporal:document-wipe function. By default, temporal:document-wipe 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:document-wipe .
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

xquery version "1.0-ml"; 
 
import module namespace temporal = "http://marklogic.com/xdmp/temporal" 
      at "/MarkLogic/temporal.xqy";

temporal:collection-create("temporalCollection", "system", "valid")

   (: 
    Creates a temporal collection, named "temporalCollection", with the 
   "system" and "valid" axes. Use temporal:axis-create 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.