How to add an Element to an Array type using MongoDB Java Driver ?

Pushing an element into an array type in MongoDB collection using Java Driver is not so obvious at the first attempt. I would share a sample program today that create a MongoDB connection and insert an element into an array type within a collection.

We are going to connect to a MongoD server installed in the local machine and running on default port, The DB name is incidentLog and the collection name is incidents. Please find the structure of the incidents collection below.

After running the program find the record to verify that the comment is added.

2 thoughts on “How to add an Element to an Array type using MongoDB Java Driver ?

  1. Pingback: Ray Ban Sale

Leave a comment

Your email address will not be published. Required fields are marked *