Hi all, I am trying to access nested value which is stored in number field like [0] ,[1]
please find the document below
{
"_id" : ObjectId("5ee7ba7ea3ac0c3192c19e58"),
"channel" : [
{
{ 0 : [ {"name":"shubham"},{"phone": " 839393"] },
{ 1 : [ {"name":"Anant"},{"phone": " 839393"] }
} ]
}
I want to find channel.0.name and channel.1.name using curser, But as field value is [0] and [1] I am not able to access the data.Please let me know if any altenative for this. I am using below query…
var cursor = db.getCollection('user_name').find({ })
while (cursor.hasNext()) {
var record = cursor.next();
print(record._id + ',' + record.channel.0.name + ',' + record.channel.1.name )}