Collection a has the following documents:
{
"_id" : ObjectId("5acd77c763c9b117b48b2e92"),
"Symbol" : "item01",
"min5" : [
{
"Symbol" : "item01",
"Date" : "2017-01-31",
"price" : 5000
},
{
"Symbol" : "item01",
"Date" : "2017-01-30",
"price" : 4999
},
{
"Symbol" : "item01",
"Date" : "2017-01-29",
"price" : 4998
}
...
],
"min10" : [
{
"Symbol" : "item01",
"Date" : "2017-01-31",
"price" : 5010
},
{
"Symbol" : "item01",
"Date" : "2017-01-30",
"price" : 5009
},
{
"Symbol" : "item01",
"Date" : "2017-01-29",
"price" : 5008
}
...
]
}
{
"_id" : ObjectId("5acd77c763c9b117b48b2e91"),
"Symbol" : "item02",
"min5" : [
{
"Symbol" : "item02",
"Date" : "2017-01-31",
"price" : 2000
},
{
"Symbol" : "item02",
"Date" : "2017-01-30",
"price" : 1999
},
{
"Symbol" : "item02",
"Date" : "2017-01-29",
"price" : 1998
}
...
],
"min10" : [
{
"Symbol" : "item02",
"Date" : "2017-01-31",
"price" : 2010
},
{
"Symbol" : "item02",
"Date" : "2017-01-30",
"price" : 2009
},
{
"Symbol" : "item02",
"Date" : "2017-01-29",
"price" : 2008
}
...
]
}
{
"_id" : ObjectId("5acd77c763c9b117b48b2e90"),
"Symbol" : "item03",
"min5" : [
{
"Symbol" : "item03",
"Date" : "2017-01-31",
"price" : 3000
},
{
"Symbol" : "item03",
"Date" : "2017-01-30",
"price" : 2999
},
{
"Symbol" : "item03",
"Date" : "2017-01-29",
"price" : 2998
}
...
],
"min10" : [
{
"Symbol" : "item03",
"Date" : "2017-01-31",
"price" : 3010
},
{
"Symbol" : "item03",
"Date" : "2017-01-30",
"price" : 3009
},
{
"Symbol" : "item03",
"Date" : "2017-01-29",
"price" : 3008
}
...
]
}
given the following conditions:
item02
, min5
, return 2
, how to query and return content in the following format:
[{"Symbol":"item02","Date":"2017-01-31","price":2000},{"Symbol":"item02","Date":"2017-01-30","price":1999}]
there is also how to add, delete, modify and check the item members of the array"s index operation subdocuments array.
I am using the mongodb package in Node.js.
I still don"t understand after looking up it on the Internet and in the document for a long time. Thank you for your advice. Thank you!