diff --git a/docs/40-CRUD/1-WHERE.mdx b/docs/40-CRUD/1-WHERE.mdx
index 325b053..2c006f6 100644
--- a/docs/40-CRUD/1-WHERE.mdx
+++ b/docs/40-CRUD/1-WHERE.mdx
@@ -129,7 +129,7 @@ Now, translate the following into a MongoDB query.
}
```
-
+
```python
@@ -141,6 +141,26 @@ Now, translate the following into a MongoDB query.
print(f"Book Title: {title} - Total Inventory: {inventory}")
```
+
+
+
+ ```Java
+ Bson filter = eq("totalInventory", 5);
+
+ Bson projection = Projections.fields(
+ Projections.include("title", "year", "totalInventory"));
+
+ List results = books.find(filter)
+ .projection(projection)
+ .into(new ArrayList<>());
+
+ if (results.isEmpty()) {
+ System.out.println("No books were found for the given query.");
+ } else {
+ results.forEach(doc -> System.out.println(doc.toJson()));
+ }
+ ```
+
@@ -185,7 +205,7 @@ Now, translate the following into a MongoDB query.
}
```
-
+
```python
@@ -196,6 +216,26 @@ Now, translate the following into a MongoDB query.
```
+
+
+ ```Java
+ Bson filter = gt("pages", 300);
+
+ Bson projection = Projections.fields(
+ Projections.include("title", "genres", "pages"));
+
+ List results = books.find(filter)
+ .projection(projection)
+ .into(new ArrayList<>());
+
+ if (results.isEmpty()) {
+ System.out.println("No books were found for the given query.");
+ } else {
+ results.forEach(doc -> System.out.println(doc.toJson()));
+ }
+ ```
+
+
@@ -246,8 +286,8 @@ Now, translate the following into a MongoDB query.
}
```
-
-
+
+
```python
books_with_genre_science_and_more_than_300_pages = books.find({"genres": "Science", "pages": {"$gt": 300}})
@@ -257,5 +297,27 @@ Now, translate the following into a MongoDB query.
```
+
+
+ ```Java
+ Bson filter = and(
+ eq("genres", "Science"),
+ gt("pages", 300));
+
+ Bson projection = Projections.fields(
+ Projections.include("title", "genres", "pages"));
+
+ List results = books.find(filter)
+ .projection(projection)
+ .into(new ArrayList<>());
+
+ if (results.isEmpty()) {
+ System.out.println("No books were found for the given query.");
+ } else {
+ results.forEach(doc -> System.out.println(doc.toJson()));
+ }
+ ```
+
+
diff --git a/docs/40-CRUD/4-INSERT-DELETE.mdx b/docs/40-CRUD/4-INSERT-DELETE.mdx
index 0af14fc..de71454 100644
--- a/docs/40-CRUD/4-INSERT-DELETE.mdx
+++ b/docs/40-CRUD/4-INSERT-DELETE.mdx
@@ -184,6 +184,34 @@ DELETE FROM reviews WHERE bookId = '0786222727';
```
+
+
+ ```Java
+ var reviews = library.getCollection("reviews");
+
+ reviews.insertMany(List.of(
+ new Document("text", "Thrilling end.")
+ .append("rating", 4)
+ .append("name", "Mark")
+ .append("bookId", "0786222727"),
+
+ new Document("text", "Very expensive")
+ .append("rating", 3)
+ .append("name", "Yun")
+ .append("bookId", "0786222727"),
+
+ new Document("text", "Must read!.")
+ .append("rating", 6)
+ .append("name", "Raj")
+ .append("bookId", "0786222727"),
+
+ new Document("text", "Extremely satisfied with the storyline!")
+ .append("rating", 5)
+ .append("name", "Lisa")
+ .append("bookId", "0786222727")));
+ ```
+
+
@@ -225,6 +253,21 @@ DELETE FROM reviews WHERE bookId = '0786222727';
reviews.delete_many({"bookId": "0786222727"})
```
+
+
+
+ ```Java
+ import static com.mongodb.client.model.Filters.eq;
+ import org.bson.conversions.Bson;
+
+ MongoCollection reviews = library.getCollection("reviews");
+
+ Bson filter = eq("bookId", "0786222727");
+
+ DeleteResult result = reviews.deleteMany(filter);
+ System.out.println(result.getDeletedCount() + " reviews deleted.");
+ ```
+
-
+
\ No newline at end of file
diff --git a/docs/40-CRUD/5-UPDATE.mdx b/docs/40-CRUD/5-UPDATE.mdx
index f25f45f..c079fe2 100644
--- a/docs/40-CRUD/5-UPDATE.mdx
+++ b/docs/40-CRUD/5-UPDATE.mdx
@@ -130,5 +130,18 @@ Executing the above command will insert a fresh new document in the collection,
```
+
+
+ ```Java
+ import static com.mongodb.client.model.Filters.eq;
+
+ var query = eq("title", "Treasure of the Sun");
+ var update = Updates.set("pages", 449);
+
+ UpdateResult updateResult = books.updateOne(query, update);
+ System.out.println("Modified document count: " + updateResult.getModifiedCount());
+ ```
+
+
-
+
\ No newline at end of file