top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

MongoDB: update a nested object with {"env":"qa"} in my updated collection with java-driver:

0 votes
429 views

My collection is like this, but I want to update a nested object with {"env":"qa"} in my updated collection with java-driver:

{ "_id" : ObjectId("5b052eeff9290437b217b1ed"), "app" : "hike", "group" : [ { "env" : "prod" }, { "env" : "test" } ]}{ "_id" : ObjectId("5b052f36f9290437b217b1ee"), "app" : "viber", "group" : [ { "env" : "prod" }, { "env" : "test" } ]}

posted May 23, 2018 by Sonu Jindal

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+2 votes

From Mongodb client, we can use db.Collection.stats() to get status of collections, such as:

+ Number of records (count) 
+ Size on disk (storageSize) 
+ Indexes (indexSizes) 
+ Average object size (avgObjSize) 

Now I want to monitor these data from web backend with Mongodb java driver, please let me know how to get them?
I've referred: http://mongodb.github.io/mongo-java-driver/3.0/driver-async/getting-started/quick-tour-admin/ but it's not enough information for me. Any pointer?

+1 vote

I have the following collections,

{ 
    "_id" : ObjectId("55884eddd00431413bdd1d97"),
    "username" : "test",
    "reports":[
       "folder 1":[{
         "file1":{
           "ceratedBy":"user1"
         },

         "file2":{
           "ceratedBy":"user2"
         } 
       }],

       "folder 2":[{
         "file1":{
           "ceratedBy":"user1"
         },

         "file2":{
           "ceratedBy":"user2"
         } 

       }]
     ]}

I now want to insert into the reports.folder 1 array say "file 3":{"cerated by":"user 3"}. Appreciate any help

+1 vote

I have a Created a Mongo Document inserted successfully to the Collection ~ "urldetls" which has 12 specific Unique keys with data in the values.

Spec: Mongodb 3.x, Java 1.7,

Question: I would like to retrieve the full document based on the value searched within all of the documents.
Problem: I cannot retrieve the document based on the key of the document.

How can i retrieve? I would like to use the Mongodb API 3.x version using java .

+1 vote

Im just doing CRUD on a mongo database with Java. My problem is when I query the database

db.getCollection("something").find()

I get the documents correctly, but the ObjectId of each document is something like this:

"_id": {
  "timestamp": **********,
  "machineIdentifier": 16375804,
  "processIdentifier": 3908,
  "counter": 9920756,
  "time": 1459641911000,
  "date": "2016-04-03T00:05:11.000+0000",
  "timeSecond": **********
}

I need to get the 12-byte ObjectId, like this:

ObjectId("507f1f77bcf86cd799439011")

How do I do that?

+1 vote

Can we connect to MongoDB Server 2.6.12 using Java Driver version 0.11? We have a constraint of upgrading Java Driver version which would require huge change in our client code. We use JDK 8 for compilation of our project. We would like to know whether it is possible to connect to MongoDB Server 2.6.12 or MongoDB Server 3.0 using Java Driver version 0.11 if we only use the limited set of features (not the functionalities that were introduced in Server version 2.6.12 or 3.0).

...