Last active
November 19, 2018 20:40
-
-
Save jmakeig/c334411d00718314092f34b820713ea5 to your computer and use it in GitHub Desktop.
Get the permissions of a MarkLogic document by URI, including role names, instead of IDs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const sec = require('/MarkLogic/security'); | |
function role(id) { | |
return fn | |
.head( | |
xdmp.invokeFunction(() => sec.getRoleNames(id), { | |
database: xdmp.database('Security') | |
}) | |
) | |
.xpath('text()') | |
.valueOf(); | |
} | |
const uri = '/helloWorld/helloWorld.sjs'; | |
xdmp.documentGetPermissions(uri).map(perm => { | |
return { capability: perm.capability, role: role(perm.roleId) }; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment