Top "Mongodb-query" questions

This tag is for questions related to querying and updating MongoDB collections, either through the mongo shell or using a programming language driver.

query in mongo Shell gives SyntaxError: missing : after property

db.movieDetails.find( { year: 2013, imdb.rating: Pg-13, award.wins: 0 }, { title: 1, _id: 0 } ).pretty(); The mongo shell returns this error 2016-08-13…

mongodb mongodb-query mongo-shell
Is it possible to flatten MongoDB result query?

I have a deeply nested collection in my MongoDB collection. When I run the following query: db.countries.findOne({},{'data.…

mongodb mongodb-query flatten
How do I rename fields when performing search/projection in MongoDB?

Is it possible to rename the name of fields returned in a find query? I would like to use something …

mongodb mongodb-query aggregation-framework
Mongodb query specific month|year not date

How can I query a specific month in mongodb, not date range, I need month to make a list of …

mongodb mongodb-query mongodb-php
MongoDB: Can't canonicalize query: BadValue Projection cannot have a mix of inclusion and exclusion

I am newer in MongoDB with CakePHP. When I write the following query it will execute very well. db.testData.…

mongodb mongodb-query
Cannot create index in mongodb, "key too large to index"

I am creating index in mongodb having 10 million records but following error db.logcollection.ensureIndex({"Module":1}) { "createdCollectionAutomatically" : false, "numIndexesBefore" : 3, "ok" : 0, "…

mongodb mongodb-query
MongoDB C# Driver - Ignore fields on binding

When using a FindOne() using MongoDB and C#, is there a way to ignore fields not found in the object? …

c# .net mongodb mongodb-query mongodb-.net-driver
What's the difference between replaceOne() and updateOne() in MongoDB?

MongoDB bulk operations have two options: Bulk.find.updateOne() Adds a single document update operation to a bulk operations list. …

mongodb mongodb-query crud
Mongo count occurrences of each value for a set of documents

I have some documents like this: { "user": '1' }, { "user": '1' }, { "user": '2' }, { "user": '3' } I'd like …

mongodb mongodb-query
MongoDB Aggregation error : Pipeline stage specification object must contain exactly one field

I am new to mongodb and trying out aggregation for first time. Here, I am trying to get the count …

mongodb mongodb-query aggregation-framework