Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js mongoose变量字符串数组中的查询$_Node.js_Mongodb_Express_Mongoose - Fatal编程技术网

Node.js mongoose变量字符串数组中的查询$

Node.js mongoose变量字符串数组中的查询$,node.js,mongodb,express,mongoose,Node.js,Mongodb,Express,Mongoose,我有以下型号: var MessageSchema = new Schema({ msgID: String, patientList: [String], created_at: Date, updated_at: Date }); 病人名单总是可变的 我正在尝试创建一个Mongoose查询,该查询可以查找给定patientID位于给定消息的patientList中的所有记录。这是我正在尝试的,但我总是得到空记录 var patientID = r

我有以下型号:

var MessageSchema = new Schema({
    msgID: String,
    patientList: [String],
    created_at: Date,
    updated_at: Date
});
病人名单总是可变的

我正在尝试创建一个Mongoose查询,该查询可以查找给定patientID位于给定消息的patientList中的所有记录。这是我正在尝试的,但我总是得到空记录

    var patientID   = req.params.patientID;
    var query = Message.find({});

    if(patientID){
        console.log(patientID);
        query = query.where(patientID).in('patientList');
    }
我看到的所有其他问题都是试图在一个具有已知值的数组中进行查询。在我的例子中,病人列表可以有任意数量的病人

有什么想法吗

现在我只得到以下输出:

{
"name": "MongoError"
}

啊。找到我的答案。。。显然,这是可行的:

query = query.where('patientList').equals(patientID);

嗨,艾哈迈德,如果我在这里发表评论,我很抱歉,但我不知道如何与你联系。我正在关注你为一个大学项目用谷歌地图制作MEAN应用程序的教程,我被一个地理空间查询卡住了。你介意看看我最近发布的这个+50悬赏问题吗?提前谢谢。