I'm getting this error while trying
db.any.aggregate([
{ "$project": { n: {$gte: 0}} }
])
I'm sure must be something obvious, but I cannot find the error. Using mongo 3.4 from the shell client
here is an example for your reference
db.inventory.aggregate(
[
{
$project:
{
qty: { $gte: [ "$qty", 250 ] },
}
}
]
)
**
note : there is slight difference when you use aggregation framework when compared to the regular querying.
**
querying without aggregation framework
db.inventory.find( { qty: { $gte: 250 } } )
References:
https://docs.mongodb.com/manual/reference/operator/aggregation/gte/index.html
https://docs.mongodb.com/manual/reference/operator/query/gte/index.html
P.S: Other comparison operators also follow the same difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With