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.

MongoDB 'unable to find index for $geoNear query'

I'm just trying to get a simple near query working. Here's a sample of my document. {"point": {"type": "Point", "coordinates": [30.443902444762696, …

mongodb geospatial mongodb-query
Mongodb : $in operator vs lot of single queries

I know MongoDB is able to handle a lot of requests/sec, but let's say I have to query a …

mongodb mongodb-query
Update field in exact element array in MongoDB

I have a document structured like this: { _id:"43434", heroes : [ { nickname : "test", items : ["", "", ""] }, { nickname : "test2", items : ["", "", ""] }, ] } Can I $set the second …

mongodb mongodb-query nosql
MongoDB - Query on the last element of an array?

I know that MongoDB supports the syntax find{array.0.field:"value"}, but I specifically want to do this for the …

arrays mongodb mongoose mongodb-query spring-data-mongodb
Object type in mongoose

I am defining a mongoose schema and definition is as follows: inventoryDetails: { type: Object, required: true }, isActive:{ type:Boolean, default:…

mongodb mongoose mongodb-query
$match in $lookup result

I have next mongo code: db.users.aggregate([ { $match: { $and: [ { UserName: { $eq: 'administrator' } }, { 'Company.CompanyName': { $eq: 'test' } } ] } }, { $lookup: { from: "companies", …

mongodb mongodb-query aggregation-framework
List all values of a certain field in mongodb

How would I get an array containing all values of a certain field for all of my documents in a …

mongodb mongodb-query database
Is there an elseif thing in MongoDB to $cond while aggregating

So I need a custom field calculated in MongoDB as follows if( field1 =="A") ->customfield=10 else if(field1 =="…

mongodb mongodb-query aggregation-framework
Get n-th element of an array in MongoDB

As part of my document in MongoDB I'm storing an array of objects. How can I query it for only …

mongodb mongodb-query aggregation-framework
Conditional $sum in MongoDB

My collection in mongodb is similar to the following table in SQL: Sentiments(Company,Sentiment) Now, I need to execute …

mongodb mongodb-query aggregation-framework