select only subdocuments or arrays

后端 未结 5 702
情书的邮戳
情书的邮戳 2021-02-06 14:59
{
    \"_id\":{
        \"oid\":\"4f33bf69873dbc73a7d21dc3\"
    },
    \"country\":\"IND\",
    \"states\":[{
            \"name\":\"orissa\",
            \"direction\"         


        
5条回答
  •  [愿得一人]
    2021-02-06 15:02

    If you don't want to use aggregate, you can do it pretty easily at the application layer using underscore (included by default):

    var country = Groops.findOne({"property":value);
    var state _.where(country, {"state":statename});
    

    This will give you the entire state record that matches statename. Very convenient.

提交回复
热议问题