$ elemmatch仅返回一个结果

时间:2018-10-31 11:44:05

标签: node.js mongodb mongoose

我有一个文件,

{
    "_id" : ObjectId("5bc864fe3cbb0d393687120b"),
    "eStatus" : "y",
    "aQuestions" : [
        {
            "eStatus" : "y",
            "_id" : ObjectId("5bcd7818f0903a1c82aeef85"),
            "sQuestion" : "aabbccdd?",
        },
        {
            "eStatus" : "n",
            "_id" : ObjectId("5bcda6aac272142b96ba77c3"),
            "sQuestion" : "sdfdsf",
        },
        {
            "eStatus" : "y",
            "_id" : ObjectId("5bcda6bfc272142b96ba77c6"),
            "sQuestion" : "vnmhjk",
        },
        {
            "eStatus" : "n",
            "_id" : ObjectId("5bd69f7516972c11234a3613"),
            "sQuestion" : "What is use of Wallet in ParadiseXtrade ?",

        }
    ],
}

我的查询:helpFaqsModel.findOne({_id: req.body._id,aQuestions: {$elemMatch: {eStatus: "y"}}})

我不确定找到eStatus: "y"

的问题列表的正确方法是什么

我想从该集合以及具有eStatus:"y"

的那个集合中找到第一个文档

0 个答案:

没有答案