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.
Inserting a document in Java applications
From the course: MongoDB Java Developer Associate Cert Prep
Inserting a document in Java applications
- Hello. In this video, you'll learn how to use the insertOne() and insertMany() methods to create single documents and perform bulk right operations in MongoDB with a Java application. We use the insertOne() method to insert a single document into a MongoDB collection. Let's look at this in action. First, we'll create a new document in the inspections collection of the sample training database. The document has a structure shown here. Notice that the sample document contains an embedded document. MongoDB recommends that you use embedded documents when you model your documents schema. We instantiate a document instance that represents the BESON document. We then initialize the various fields and values by using the document classes append() method. The document has ID, date and address fields among others. MongoDB documents have an ID field that uniquely identifies each document in a collection. We can think of this as being equivalent to a primary key. We can either provide a value…
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
-
-
-
-
-
-
-
-