From the course: MongoDB Java Developer Associate Cert Prep
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Updating documents in Java applications
From the course: MongoDB Java Developer Associate Cert Prep
Updating documents in Java applications
- Hello. In this video you'll learn how to perform single and multiple document updates in MongoDB with a Java application. To do this, we'll use the updateOne() and updateMany() Mongo collection methods. Two ways to update a document in Mongo DBR, update the value of an existing field or define a new field in value. Note that this is not an exhaustive list of available update operations. For brevity, we'll assume that the Mongo client and Mongo collection instances have been already initialized. We use the Mongo collection updateOne() method when we need to update a single document that matches some specified criteria. The updateOne() method accepts a query filter and an update document. To demonstrate the updateOne() method, let's assume that we have bank account documents and an accounts collection, and we need to increase the balance of John Doe's account by 100. Additionally, we want to add an account status field that shows if the account is active or dormant. To do this, we'll…
Contents
-
-
-
-
-
-
-
-
-
Working with MongoDB documents in Java2m 33s
-
(Locked)
Inserting a document in Java applications2m 35s
-
(Locked)
Querying a MongoDB collection in Java applications2m 6s
-
(Locked)
Updating documents in Java applications2m 55s
-
(Locked)
Deleting documents in Java applications2m 2s
-
(Locked)
Creating MongoDB transactions in Java applications2m 52s
-
(Locked)
Review of MongoDB CRUD operations in Java1m 3s
-
-
-
-
-
-
-
-