MongoDB Integration with Google Sheets to Update documents

So, I’m using Realm to integrate my Google Sheet data with the MongoDB Database.

I basically want to compare each row of Google Sheet with MongoDB Documents on the basis of ID and if there’s not a match then I want it to insert a document and if the id matches with one of the existing documents then I want it to check and update values.

This is what I’ve done so far (I’ve just done it for TransformX_Vendor_Name for now but I want it to check for all the columns and not just one ):

exports = async function(payload,response) {
 const mongodb ="mongodb-atlas");
 const eventsdb = mongodb.db("CPaaS_Decision_Engine");
 const eventscoll = eventsdb.collection("CPaaS_Vendors");
 var body = JSON.parse(payload.body.text());
 var TransformX_Vendor_Name = body.TransformX_Vendor_Name;
 const result= await eventscoll.count({ "TransformX_Vendor_Name": TransformX_Vendor_Name });

    if(result.count > 0 ) {
        response.setBody( JSON.stringify({TransformX_Vendor_Name}) );    
      } else {
  const insert= await eventscoll.insertOne(payload.query);
  var id = result.insertedId.toString();

I’m new to MongoDB Realm. Any help would be really helpful, thank you!