I'm trying to do a find query using a string and a number as fields. The query works while looking for the string alone. How can I make it work for number as well?
var check = request.body.cookie; // String
var tok = request.body.token; // It's a number
db.collection("users").find({'name':check, 'token':tok}).toArray(function(err, rows) {
if(!rows.length)
{
console.log("No data found");
}
});
A sample collection is given below
> db.users.find()
{ "_id" : ObjectId("608be0dc8b83df0248ed2fc1"), "name" : "John", "age" : "18", "gender" : "M",
"country" : "RR", "socketid" : "1",
"token" : "5907" }
console.log(typeof request.body.token);