tde.templateInsert( uri as String, root as Node, [permissions as Sequence], [collections as String[]] ) as emptySequence
This function validates the template, inserts the template as a document into the tde collection of the schema database (if executed on the content database) with the default permissions, and reindexes the database.
Note that, when a template is inserted, only those document fragments affected by the template are re-indexed. For more information, see Validating and Inserting a Template in the Application Developer's Guide.
tde-admin
role is required in order to insert a template into the
schema database.
Note that, unlike the other tde
functions, this is a library function
that requires that you import the tde.xqy
module.
declareUpdate(); var tde = require("/MarkLogic/tde.xqy"); var template = xdmp.toJSON( { "template":{ "context":"/MedlineCitation/Article", "rows":[ { "schemaName":"Medical", "viewName":"Publications", "columns":[ { "name":"ID", "scalarType":"long", "val":"../MedlineID" }, { "name":"ISSN", "scalarType":"string", "val":"Journal/ISSN" } ] } ] } } ); tde.templateInsert("Template.json", template); // Inserts the template as the Template.json file.