Last active
October 4, 2021 15:52
-
-
Save ziad-saab/41eca04a72d8038493ba to your computer and use it in GitHub Desktop.
Get a list of a user's roles from Parse, including child roles, up to a certain depth
This file contains hidden or 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
// Maximum depth is 3, after that we get a "" error from Parse | |
function getUserRoles(user) { | |
var queries = [ | |
new Parse.Query('_Role').equalTo('users', user) | |
]; | |
for (var i = 0; i < 2; i++) { | |
queries.push(new Parse.Query('_Role').matchesQuery('roles', queries[i])); | |
} | |
return user.rolesPromise = Parse.Query.or.apply(Parse.Query, queries).find().then( | |
function(roles) { | |
return roles.map(function(role) { | |
return role.get('name'); | |
}); | |
} | |
); | |
} |
@coderofsalvation No question from me. I just posted my TS version of the code, in case anyone needed it.
hehe indeed my bad 😂
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hm it is somewhat confusing that you're asking for a TS version of a TS snippet. What is the real problem/context behind your question?