Atlas Trigger Issue

Hi Team

I am trying to write a script in Atlas trigger.

but getting below error when i am executing simple function call.

{“message”:“‘countDocuments’ is not a function”,“name”:“TypeError”}

Service name, db and collection names are correct. Can anyone help on this

this is the script

exports = async function() {
const collection =“XXXXXXX”).db(“XXXxxx”).collection(“Xxxccxc”);
const count = await collection.countDocuments();
console.log(“Count:”, count);


Hi Dinesh,

Have you tried Count Documents in the Collection count()?


Hi Jason

There is issue with any function (DeleteMany, DeleteOne etc) i am using in the script.

Is there any class or library that has to be included in the script.


With regards to the original topic about countDocuments(), I was not able to find this in the Atlas App Services - MongoDB API reference. However, this contains the deleteMany() and deleteOne() functions. Can you further clarify what you mean by “issue”?