Sunday 28 May 2017

Finding element on Mongodb collection array field

My usuario collection:

{ 
"_id" : ObjectId("5817a06de4e150a1418b4567"),  
"idStore" : [

"58177ca2e4e15041058b4567",

"5817a192e4e150d7098b4567",

"5817bbb3e4e15020778b4567"

] }

I'm trying to find an element on idStore field:

var vIdLoja = "5817a192e4e150d7098b4567";    

db.collection('usuario').find({idStore: { $elemMatch: { $gte: vIdLoja, $lte: oIdLoja } }}).toArray(function(err, result) {

or

var vIdLoja = "5817a192e4e150d7098b4567";

db.collection('usuario').find({idStore: vIdLoja}).toArray(function(err, result) {

The result is the same: empty/undefined driver: MongoClient

How can I solve that issue?



via Marcio Gomes

No comments:

Post a Comment