This is the Schema:
var userschema = new mongoose.Schema({
user: String,
pass: String,
imagen: [{
title: String,
author: String,
description: String,
index: Number,
path: String,
}]
});
I'm trying with 'foomodel.find', to find inside the imagen array of the Schema, a element with an specific property, I mean:
usermodel.find({ user: foo, 'imagen.index': 1 }, function (err, imagen){
if(err) throw err;
console.log(imagen);
});
In the console, I received this [], when I want to received the properties of the imagen array's element, that has the index as one. I checked it exist. Any solution...?
Thank's advance!
I think you need to use $elementMatch:
usermodel.find({ user: foo, "imagen": {"$elemMatch":{"index": 1 }},
function (err, imagen){
if(err) throw err;
console.log(imagen);
});