Create atlas trigger for Drop collection while update an document with specified field in another Collection

Hi Team,

I need your help to create a trigger to drop collection, while a specified field updated in another collection.

Sample case:
Here is the one sample collection of ‘meetings’:

{
_id:1,
meeting_id:123,
is_active:true
}

And there is another collections like concatenation of “chat & meeting_id” i.e., **chat_123** example with the above meetings collection.

With every meeting_id has Another collection like chat_123, chat_124, chat_125,.............

I need help to get drop the “chat_123” collection when update **is_active** field with **false** in meetings collection.

Please help me on this .

Thanks in advance.

Hi @Lokesh_Reddy1 and welcome to the MongoDB community!!

Dropping a collection using the Atlas triggers is not possible as of today. If I may suggest an alternative, you might achieve the same by implementing the drop command in the application, if it’s applicable to your use case.

Also,

If I understand correctly, if you have a lot of chats, you will also have a lot of collections. Although there is technically no limit to the number of collections in MongoDB, if there are too many, you might hit some hardware-related limitations. Is there a reason for this design in particular? Will it be possible to implement this using a variation of the bucket pattern instead?

Let us know if you have any further questions.

Best Regards
Aasawari