Loading TOC...

MarkLogic 9 Product Documentation
xdmp:database-node-query-rolesets

xdmp:database-node-query-rolesets(
   $nodes as node()*,
   [$options as xs:string*]
) as element(sec:query-rolesets)*

Summary

Return a sequence of query-rolesets that are required for proper querying of the given database nodes with Element Level Security.

Parameters
$nodes A sequence of database nodes.
options The default is ().

Options include:

"all"
Return all query-rolesets, even if they are already configured.
"unconfigured"
Return only those query-rolesets that are not configured.

Required Privileges

http://marklogic.com/xdmp/privileges/database-node-query-rolesets

Usage Notes

"Nodes" is a sequence of database nodes. If an array is passed in, it will be treated as one array node. Use Sequence.from to convert an array of nodes to a sequence of nodes when necessary.

If neither "all" nor "unconfigured" is present, it defaults to "all".

Example

xdmp:database-node-query-rolesets(
    fn:doc("/example.xml"), ("all"))

Example

xquery version "1.0-ml";
import module namespace sec = "http://marklogic.com/xdmp/security" 
  at "/MarkLogic/security.xqy";
(: run this against the Security database :)
let $qry := 'xdmp:database-node-query-rolesets(fn:doc("/example.xml"), ("all"))'
let $qry-rolesets := 
xdmp:eval($qry, (),<options xmlns="xdmp:eval">
                   <database>{xdmp:database(YOUR_DB_NAME)}</database>
                 </options>)
return
sec:add-query-rolesets($qry-rolesets)
=>
(: returns the role id(s) associated with the query rolesets :)

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