Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongoose greater than and equal

how to get greater than or equal integer values from Mongodb using Mongoose? assume that below list

list = [134,56,89,89,90,200] //Marks field

want to get values equal or greater than 89, result set must be [89,90,200] in my query I was able to get values greater than 89, I want to get it with 89

let x = 89;
query.find().where('marks').gt(x);
like image 861
123Ex Avatar asked Apr 26 '18 12:04

123Ex


1 Answers

I don't know what version of mongodb you are using. But this is what available in the latest releases.

$gte selects the documents where the value of the field is greater than or equal to (i.e. >=) a specified value

query.find( { marks: { $gte: 89} } )

Here

like image 120
Muhammad Usman Avatar answered Oct 05 '22 16:10

Muhammad Usman