Duplicate Entries

I am modifying an object with beforeSave trigger with this code.

Moralis.Cloud.beforeSave("Notifications", async function(request) {
      let dappQuery = new Moralis.Query("Channels");
      dappQuery.equalTo("channelId", request.object.get("ChannelId"));
      let dapp = await dappQuery.first();
      let channelDetails = dapp.get("details");
      request.object.set("channel", channelDetails);
      return request.object
});

But it is creating two entries in the Channels collection with confirmed=True and confirmed=False.
Please let me know how can I have a single entry only.

you can check that confirmed flag and execute code only when confirmed is True

a better option is to use your now flag, like a processed column in that table, and set it to true after you processed that row

Is there a way we can decrease the confirmed flag time?

you can not decrease that confirmed time, it is fixed per chain as a number of blocks until we consider a transaction as being confirmed