# Bulk update Object ACL

**URL:** <https://community.parseplatform.org/t/bulk-update-object-acl/1879>\
**Category:** Cloud Code\
**Created:** [August 4, 2021, 3:21pm UTC](https://community.parseplatform.org/t/bulk-update-object-acl/1879 "2021-08-04T15:21:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![himanshuagarwal456](https://community.parseplatform.org/user_avatar/community.parseplatform.org/himanshuagarwal456/32/745_2.png) [@himanshuagarwal456](https://community.parseplatform.org/u/himanshuagarwal456)\
**Post date:** [August 4, 2021, 3:21pm UTC](https://community.parseplatform.org/t/bulk-update-object-acl/1879/1 "2021-08-04T15:21:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![davimacedo](https://community.parseplatform.org/user_avatar/community.parseplatform.org/davimacedo/32/316_2.png) [@davimacedo](https://community.parseplatform.org/u/davimacedo)\
**Post date:** [August 4, 2021, 5:27pm UTC](https://community.parseplatform.org/t/bulk-update-object-acl/1879/2 "2021-08-04T17:27:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![himanshuagarwal456](https://community.parseplatform.org/user_avatar/community.parseplatform.org/himanshuagarwal456/32/745_2.png) [@himanshuagarwal456](https://community.parseplatform.org/u/himanshuagarwal456)\
**Post date:** [August 4, 2021, 5:40pm UTC](https://community.parseplatform.org/t/bulk-update-object-acl/1879/3 "2021-08-04T17:40:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![davimacedo](https://community.parseplatform.org/user_avatar/community.parseplatform.org/davimacedo/32/316_2.png) [@davimacedo](https://community.parseplatform.org/u/davimacedo)\
**Post date:** [August 4, 2021, 5:49pm UTC](https://community.parseplatform.org/t/bulk-update-object-acl/1879/4 "2021-08-04T17:49:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![himanshuagarwal456](https://community.parseplatform.org/user_avatar/community.parseplatform.org/himanshuagarwal456/32/745_2.png) [@himanshuagarwal456](https://community.parseplatform.org/u/himanshuagarwal456)\
**Post date:** [August 4, 2021, 5:57pm UTC](https://community.parseplatform.org/t/bulk-update-object-acl/1879/5 "2021-08-04T17:57:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![himanshuagarwal456](https://community.parseplatform.org/user_avatar/community.parseplatform.org/himanshuagarwal456/32/745_2.png) [@himanshuagarwal456](https://community.parseplatform.org/u/himanshuagarwal456)\
**Post date:** [August 4, 2021, 6:35pm UTC](https://community.parseplatform.org/t/bulk-update-object-acl/1879/6 "2021-08-04T18:35:39Z")

</div>

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);
    console.log(JSON.stringify(result));
} 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 😃
