Mongodb Update Multiple Document, Insert if not Exist

Mongodb Update Multiple Document, Insert if not Exist

If upsert:true is set then mongodb insert new document if exist. My below query working fine for single document. Unique Index:- {fid:1,uniqueid:1,atype:1,ftype:1}

If upsert:true is set then mongodb insert new document if exist. My below query working fine for single document. Unique Index:- {fid:1,uniqueid:1,atype:1,ftype:1}

db.Notification.updateMany(
  {fid : 103,uniqueid:1001,atype:1,ftype:6}
  ,{ $set: { epoch: 1548484978658,actionbyuserid: 110, title: 'Good Morning To All'}}
  ,{upsert:true}
);

But when execute below query it is not inserting new documents for not matched documents;

db.Notification.updateMany(
 {fid : {$in:[101,102,103]},uniqueid:1001,atype:1,ftype:6}
  ,{ $set: { epoch: 1548484978658,actionbyuserid: 110, title: 'Good Morning To All'}}
,{upsert:true}
)

Is there other to check and insert not found documents ?

mongodb

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

MongoDB Database and java applications

Enroll for free demo to acquire the best knowledge on the schema-less database from live industry experts through MongoDB training

Which is the Best MongoDB GUI?

Our MongoDB Online Training provide you to learn about MongoDB strategies with realty. Our MongoDB Online Training also includes live sessions, live Projects, and much

Improve the MongoDB Aggregation Framework

Our MongoDB Online Training provide you to learn about MongoDB strategies with realty. Our MongoDB Online Training also includes live sessions, live Projects, and much

MongoDB – Database, Collection, and Document

Our MongoDB Online Training provide you to learn about MongoDB strategies with realty. Our MongoDB Online Training also includes live sessions, live Projects, and much

MongoDB brings database product range under one cloudy roof

Enroll for free demo to acquire the best knowledge on the schema-less database from live industry experts through MongoDB training