MarkLogic :如何获取具有 rest-reader、rest-writer 权限的数据库中所有文档的计数?
MarkLogic : How to get the count of all documents in a database with rest-reader, rest-writer permission?
我们最近使用 corb 为数据库中集合中的所有文档设置了权限(rest-reader、读取和 rest-writer、更新)。此 activity 是针对集合中的 1000 万份文档完成的。
xquery version "1.0-ml";
declare variable $URI as xs:string external;
xdmp:document-add-permissions($URI,
(xdmp:permission("rest-reader", "read"),
xdmp:permission("rest-writer", "update")))
如何获取数据库中具有权限(rest-reader、read and rest-writer、update)的文档总数?
我不会直接迭代文档和检查权限,但会为此利用安全性。作为管理员,您首先 运行 一些估计:
xdmp:estimate(collection()), (: total count :)
xdmp:estimate(collection('mycollection')) (: count of all in that collection :)
然后对仅具有 rest-reader 角色的测试用户重复相同的估计:
xdmp:invoke-function(function() {
xdmp:estimate(collection()), (: total count visible to rest-reader user :)
xdmp:estimate(collection('mycollection')) (: count of all in that collection visible to rest-reader user:)
}, (), map:entry("user-id", xdmp:user('myrestreaderuser')))
通过从其他 reader 用户中减去管理员计数,您可以得出有多少人没有获得您尝试申请的权限。
HTH!
我们最近使用 corb 为数据库中集合中的所有文档设置了权限(rest-reader、读取和 rest-writer、更新)。此 activity 是针对集合中的 1000 万份文档完成的。
xquery version "1.0-ml";
declare variable $URI as xs:string external;
xdmp:document-add-permissions($URI,
(xdmp:permission("rest-reader", "read"),
xdmp:permission("rest-writer", "update")))
如何获取数据库中具有权限(rest-reader、read and rest-writer、update)的文档总数?
我不会直接迭代文档和检查权限,但会为此利用安全性。作为管理员,您首先 运行 一些估计:
xdmp:estimate(collection()), (: total count :)
xdmp:estimate(collection('mycollection')) (: count of all in that collection :)
然后对仅具有 rest-reader 角色的测试用户重复相同的估计:
xdmp:invoke-function(function() {
xdmp:estimate(collection()), (: total count visible to rest-reader user :)
xdmp:estimate(collection('mycollection')) (: count of all in that collection visible to rest-reader user:)
}, (), map:entry("user-id", xdmp:user('myrestreaderuser')))
通过从其他 reader 用户中减去管理员计数,您可以得出有多少人没有获得您尝试申请的权限。
HTH!