Here is my Simple Find Query in Mongoose
CustomerModel.find({},function (err, result) {
console.log(result);
})
In Console
[ { _id: 5a081297b028f45d691f0257,
name: 'Panindra',
contact: { _id: 5a08191b5667530e0844f3a8, mobile: [Array] } } ]
I was expecting my Mobile Result shoulde some thing like this
mobile:['88842XXXXXX']
but I am getting mobile:[Array];
Here is my MONGOS SHELL QUERY RESULT :
db.getCollection('tests').find({})
{ "_id" : ObjectId("5a081297b028f45d691f0257"), "name" : "Panindra", "contact" : { "mobile" : [ "88842XXXXXX" ] } }
and Here is my SCHEMA for Customer and Contact ..
var CustomerSchema = new Schema({
name: String,
contact: new Schema({
mobile:[String]
})
How to Get Mobile Value in find () Query ??
NOTE : BUT IF I QUERY FOR findOne() ? I am getting the mobile numbers , What i am missing ? here is query
CustomerModel.findOne({name:"Panindra"},function (err, result) {
console.log(result);
})
and the result ( as I desired)
IN CONSOLE
{ _id: 5a081297b028f45d691f0257,
name: 'Panindra',
contact: { _id: 5a081a8ea0fba80b10c0e1c6, mobile: [ '88842XXXXX' ] } }