Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run aggregate query in mongodb client on RockMongo or mViewer

I've just started using mongo db, I'm using rockmongo client and my ubuntu terminal as another client. I' ve realized the query using group aggregation like this:

 db.archiveImpl.group(
 {
   key: {accountID: true, phone: true },
   cond: {'userId': "oiuoifas2309u"},
   reduce: function(object, prev){ },
   initial:{}

 }

)

And the above query is not getting run in the rockmongo , I initially thought that the query was wrong. and I ran in on the terminal which pulls me the data. So I downloaded and installed mViewer and it didn't work either so I believe there is a way to run these kind of queries in mongo web clients

thanks for reading this .

like image 555
black sensei Avatar asked Jun 21 '12 17:06

black sensei


1 Answers

You can run aggregate query in "tools->command" panel in your homepage of rockmongo. You may enter query in the input panel like this:

{ 
  aggregate : "ns",                                          
  pipeline : [
               ...
             ]                
}

That will be ok! I have tried, and it works!

Full Example:

{ aggregate : "COLLECTION_NAME",
  pipeline : [
    { $unwind : "$SUB_ARRAY" },
    { $match: {"SUB_ARRAY.field": "value"}},
  ]
}
like image 71
sososo425 Avatar answered Nov 15 '22 09:11

sososo425