A pipeline execution triggered with a database trigger in Atlas

Hi @Sumedha_Mehta1

I basically try to use the code I got here as a starter for scheduled triggers, supposing the function (triggered by a database trigger, by a collection change) to be executed might be the same as that one, but it is probably wrong.
The code ( without the pipeline, which is working properly by running manually ) is:

exports = async function() {
var db = <database>;
var sourceColl = <sourceCollection>;
var collection = context.services.get("Cluster0").db(db).collection(sourceColl);
        var pipeline =[
 
    ]; //Paste pipeline
    
await collection.aggregate(pipeline).toArray();
}

Thank you!