From the course: MongoDB Node.js Developer Associate Cert Prep
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Replacing a document in MongoDB
From the course: MongoDB Node.js Developer Associate Cert Prep
Replacing a document in MongoDB
- Hello, in this video, you'll learn how to replace a document in MongoDB. Sometimes documents are incorrectly inserted into a collection. Luckily, it's a simple process to replace those inserted documents within your collection. Let's get started. To replace a single document, we'll use the replaceOne method. This method accepts three arguments, a filter, a replacement document, and an options object. The options object is not required and won't be taught in this video. To understand how the replaceOne method works, let's use an example. Imagine you work for a publisher that has a database for released and unreleased computer science books. Unreleased books still get an entry in the database, but because they're incomplete, some of them have temporary titles or missing data. We can replace any entry or document that has missing or incorrect data with an updated document that contains the accurate information, but…
Contents
-
-
-
-
-
-
- (Locked) Replacing a document in MongoDB3m 15s
- (Locked) Updating MongoDB documents by using updateOne()5m 56s
- (Locked) Updating MongoDB documents by using findAndModify()2m 35s
- Updating MongoDB documents by using updateMany()3m 2s
- (Locked) Deleting documents in MongoDB2m 37s
- (Locked) MongoDB CRUD operations: Replace and delete documents review44s
- (Locked)
-
-
-
-
-
-
-
-
-