We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4e21760 commit 0c67f86Copy full SHA for 0c67f86
mongodb/MongoModify.java
@@ -0,0 +1,25 @@
1
+package com.zetcode;
2
+
3
+import com.mongodb.MongoClient;
4
+import com.mongodb.client.MongoCollection;
5
+import org.bson.Document;
6
7
+import static com.mongodb.client.model.Filters.eq;
8
9
+public class MongoModify {
10
11
+ public static void main(String[] args) {
12
13
+ try (var mongoClient = new MongoClient("localhost", 27017)) {
14
15
+ var database = mongoClient.getDatabase("testdb");
16
17
+ MongoCollection<Document> collection = database.getCollection("cars");
18
19
+ collection.deleteOne(eq("name", "Skoda"));
20
+ collection.updateOne(new Document("name", "Audi"),
21
+ new Document("$set", new Document("price", 52000)));
22
23
+ }
24
25
+}
0 commit comments