Articles → MONGODB → Replaceone Function In MongodbReplaceone Function In MongodbIn this article, we will discuss the replaceOne function in MongoDB.Purpose The replaceOne function replaces the single document within the collection based on the filter criteria.Example Consider the following documents: -Click to EnlargeWe require to replace the subject name with MongoDB where the subject name is equal to MongoDB1.So, the query would be: -db.Articles.replaceOne({subject:"MongoDB1"}, {subject:'MongoDB1'})Click to EnlargeOutput Click to EnlargePosted By - Karan Gupta Posted On - Saturday, February 11, 2023 Query/Feedback Your Email Id** Subject* Query/Feedback Characters remaining 250**
db.Articles.replaceOne({subject:"MongoDB1"}, {subject:'MongoDB1'})
Query/Feedback