收藏
回答

如何获取集合中某个数组字段的部分匹配的值?

云数据库上有个集合:class,数据如下:

[

    {

        "name":"一班",

        "students":[

            {

                "studentNo": "101",

                "studentName": "张一"

            }, {

                "studentNo": "102",

                "studentName": "王一"

            }

        ]

    },{

        "name":"二班",

        "students":[

            {

                "studentNo": "201",

                "studentName": "李二"

            }, {

                "studentNo": "202",

                "studentName": "赵二"

            }

        ]

    }

]

我现在有个学号列表,比如["101", "202"],我想查询class集合,匹配这个学号列表,查询列表中存在的学生,返回的结果中students里只包含匹配的学生信息,也就是说想得到下面的目标数据,请问这个如何实现?

[

    {

        "name":"一班",

        "students":[

            {

                "studentNo": "101",

                "studentName": "张一"

            }

        ]

    },{

        "name":"二班",

        "students":[

            {

                "studentNo": "202",

                "studentName": "赵二"

            }

        ]

    }

]


最后一次编辑于  09-02  (未经腾讯允许,不得转载)
回答关注问题邀请回答
收藏

1 个回答

  • 邓坤力
    邓坤力
    09-02

    字段投影的时候暂不支持对象数组,接下来会支持上

    09-02
    赞同
    回复
问题标签