I'm trying to do the following, and my question is commented inline. How can I send both the registeredUsersRole and the users from query.find() to the next then in the chain without creating a nested then in there?
// ...
registeredUsersRoleQuery.first({
useMasterKey: true
}).
then(function(registeredUsersRole) {
// This means that role was found, so simply return it to the next promise
return registeredUsersRole;
}, function() {
// This means that role wasn't found, so create it and return it to the next promise
var registeredUsersRoleAcl = new Parse.ACL();
registeredUsersRoleAcl.setPublicReadAccess(false);
registeredUsersRoleAcl.setPublicWriteAccess(false);
return new Parse.Role(registeredUsersRoleName, registeredUsersRoleAcl).save{
useMasterKey: true
});
}).
then(function(registeredUsersRole) {
var query = new Parse.Query(Parse.User);
query.equalTo('verificationCodeVerified', true);
// How can I send both the registeredUsersRole and the users from
// query.find() to the next then in the chain without creating
// a nested then in here?
query.find({
useMasterKey: true
}).
then(function(allVerifiedUsers) {
registeredUsersRole.getUsers().
add(allVerifiedUsers);
return registeredUsersRole.save();
});
}).
then(function() {
// How do I have both the registeredUsersRole and the users here?
});