Hello @Shanvitha ,
Thanks for the ask , i think you can make a small change on the reference pipeline . You need to switch from Update/Insert to Upsert . Please see the snaphot below .
Thanks Himanshu
Please do consider to click on "Accept Answer" and "Upvote" on the post that helps you, as it can be beneficial to other community members.