MongoError:$ all需要数组
我正在使用sailsjs mongodb和node.js我得到错误在mongodb查询错误,请帮助!
我想要得到的结果符合$ all:[senderID,sendToID]
这是我在MongoDB中的文档“消息”。
{ “用户”:[ “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(函数(err,detail){ 如果(err){ 执行console.log(ERR) } else { console.log(detail)} });
这会返回错误
{[MongoError:$ all需要数组] name:'MongoError'}
我正在遵循文档http://docs.mongodb.org/manual/reference/operator/query/all/,但仍然不知道是什么导致问题
在Waterline中,目前没有办法查询embeddedlogging。 您可以在sails-mongo中下载到本地mongo驱动程序,然后运行查询。 以下应该给你你需要的东西。
User.native(function(err, collection) { collection.find({ users: { $all: [ "52ed09e1d015533c124015d5", "52ed4bc75ece1fb013fed7f5" ] }}).toArray(function(err, docs) { // Do something here }); });