Bulk update Object ACL

I am looking for a way to bulk update object ACL or apply CLP to existing objects.
We have a use case where we need to fetch a copy of live database and run cloud functions on top of it to serve resources to a UI. However, since the CLP or Object ACL are not set at time of data creation. We are trying to find a way to bulk update the ACLs for already created Objects. The normal Parse queries take quite a while as some classes have >200k objects. Have also tried to use Aggregation queries but haven’t made much headway.
Would appreciate any help/comment. TIA

If that’s something that you need to do a single time, maybe the best way is directly on mongo db.

Thanks @davimacedo I did try updating them at mongo level but wasn’t successful, maybe was doing something wrong.
I do have a couple of questions about it:

  1. For updating ACL at Mongo level do I just need to update the _acl object or I need to update _wperm and _rperm as well?
  2. Last time I tried I saw changes in mongo but same were not reflected on Parse dashboard. Is there an additional step I need to do to ensure updated ACLs are picked up by Parse?
    Thanks again, really appreciate your help.

I actually don’t know by mind exactly how ACL is stored and we’d need to check the code for that. But I believe the easiest way would be updating a single object via dashboard and checking how the ACL is stored for that object. So, the way I’d try to do:

  • First update a single object using the dashboard
  • Then check mongodb to see how Is the ACL setting stored for this object
  • Try to update the same change to another object
  • After refreshing the browser, you should see the change on the dashboard
  • If successful, apply to the other objects

If you don’t succeed, share what you have in the steps and the mongodb commands you used, and I can try to help.

1 Like

Neat!! Thats a good suggestion, going to try this out. Will keep you posted :beers:

1 Like

export async function updateACL(){
const updateACLRperm = {
$push: { _rperm: “role:”}

const updateACLObj = {
    $set: {"_acl.role:<role>": {"r":true}}
try {
    const client = await MongoClient.connect(process.env.DATABASE_URI);
    const db = client.db(process.env.DB_NAME);
    const result = await db.collection(<CollectionName>).updateMany({},updateACLObj);
} catch (error) {
    AuditLogger.error(`Failed with error :${error}`);


I think this worked. I can also see ACL updated on parse dashboard. Not sure what I was doing wrong earlier. Thanks for all the help. Had to run two update queries but this updated 200k objects in under a minute :smiley: