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.
Querying a MongoDB collection in Java applications
From the course: MongoDB Java Developer Associate Cert Prep
Querying a MongoDB collection in Java applications
- Hello. In this video we'll explore the find() and find.first() methods. These methods are used to retrieve documents from a MongoDB collection in a Java application. We'll also examine how query predicates allow us to define more efficient queries by using the Filters builder class. The first query will define use as the accounts collection. Say we want to find all accounts that have a balance greater than or equal to 1000. Before we start writing this query, it's important to note that the query specifies two conditions, that the balance is greater than or equal to 1000, and that the account type is checking. Query conditions, also known as predicates, are expressed as filters by using the Filters class. To create this query, we'll use find(). For this video, we'll assume that we have already instantiated the MongoClient and MongoCollection instances. The MongoCollection class provides an overloaded find() method that accepts a filter. The find() method returns a find iterable…
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
-
-
-
-
-
-
-
-