我正在使用sailsjs mongodb和node.js我收到错误跟随mongodb查询错误请帮忙!
我想得到那些与 $all: [ senderID , sendToID ] 完全匹配的消息的结果
这是我在mongodb的文件"message" .
{
"users": [
"52ed09e1d015533c124015d5",
"52ed4bc75ece1fb013fed7f5"
],
"user_msgs": [],
"createdAt": ISODate("2014-02-04T11:59:53.220Z"),
"updatedAt": ISODate("2014-02-04T11:59:53.220Z"),
"_id": ObjectID("52f0d639b922c9142763c336")
}
现在我想查询
Message.find({ users : { $all: [ msg.sender , msg.sendTo ] } })
.done(function (err, detail) {
if (err) {
console.log(err)
} else {
console.log( detail)}
});
返回错误
{[MongoError:$all requires array] name:'MongoError'}
我正在关注文档http://docs.mongodb.org/manual/reference/operator/query/all/但仍然不知道是什么原因导致了问题
1 回答
在Waterline中,目前没有办法查询嵌入式记录 . 您可以在sails-mongo中下载到本机mongo驱动程序并运行查询 . 以下内容应该为您提供所需 .