javascript - Trying to retrieve all users of a role -
i'm trying retrieve of users of given role display display users in role.
i.e. users in role superadmin screen list of users in role baseuser.
i tried
var query = (new parse.query(parse.role)); query.equalto("name", "baseuser"); query.include("users") query.find({ success: function(role) { console.log(role) }})
this gives me 400 bad request.
i tried
var query = (new parse.query(parse.role)); query.equalto("name", "baseuser"); query.find({ success: function(role) { query = (new parse.query(parse.user)); query.equalto("role",role) query.find({success: function(users) { console.log(users) }}) }})
similarly 400 bad request. advice?
updated
var query = (new parse.query(parse.role)); query.equalto("name", "superadmin"); query.first({ success: function(role) { query = (new parse.query(parse.user)); query.equalto("role",role) query.find({success: function(users) { console.log(users) }, error: function(error) { console.log(error); }}) }})
i changed top (outer) query find first, array not 1 element , in fact need 1 matching role back. empty array not error. still not users though
updated
figured out
var query = (new parse.query(parse.role)); query.equalto("name", "superadmin"); query.first({ success: function(role) { role.relation('users').query().find({success: function(users) { console.log(users) }}) }})
this pull in users relation , allow query on it.
as per docs, error code of 400 still include response error. in case, haven't included error:
callback. change query like:
query.find({ success: function(users) { console.log(users); }, error: function(error) { console.log(error); } });
so can see actual error is.
Comments
Post a Comment