Im trying to add a Role’s read/write ACL to all objects in a Class. Im testing doing it only to the first 5 objects, just to see if it works.
But Im getting the following in the console.
(node:17320) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'error' of undefined
at /Users/omarojo/Documents/GenerateProjects/GenerateParseOld/Generate-Parse/cloud/giveAdminACLToAllPosts.js:28:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:17320) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:17320) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Here is my JOB
const { query } = require(“express”);
Parse.Cloud.job("giveAdminACLToAllPosts", function(request, status) {
var postQuery = new Parse.Query("Post");
postQuery.limit = 5;
postQuery.descending("createdAt");
postQuery
.each(
function(post) {
var acl = post.getACL();
acl.setRoleWriteAccess("Administrator", true);
acl.setRoleReadAccess("Administrator", true);
post.setACL(acl);
console.log("adding Admin Write Access to Post:" + post);
return post.save(null, { useMasterKey: true });
},
{ userMasterKey: true }
)
.then(
function() {
status.success("successfully added Admin Write");
},
function(error) {
status.error("error adding Admin Write to Post: " + error.message);
}
);
});