Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.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
Javascript 运算符中的MongodB在不应返回的空白数组上返回_Javascript_Mongodb_Coffeescript_Meteor - Fatal编程技术网

Javascript 运算符中的MongodB在不应返回的空白数组上返回

Javascript 运算符中的MongodB在不应返回的空白数组上返回,javascript,mongodb,coffeescript,meteor,Javascript,Mongodb,Coffeescript,Meteor,我在客户端上运行的coffeescript中有一个模板函数: Template.leftNav.starred = () -> user = Meteor.user() if ! user return else starredPages = user.profile.starredPages starred = Entries.find({ _id :{in: starredPages}}).fetch() Mete

我在客户端上运行的coffeescript中有一个模板函数:

Template.leftNav.starred = () ->
   user = Meteor.user()
   if ! user 
        return
   else
        starredPages = user.profile.starredPages
        starred =  Entries.find({ _id :{in: starredPages}}).fetch()
Meteor.user()
返回

Object {_id: "AHSwfYgeGmur9oHzu", profile: Object}
  _id: "AHSwfYgeGmur9oHzu"
  profile: Object
  starredPages: Array[4]
     0: "asdasdasdasdasd"
     1: "abc123"
     2: "blobby"
     3: "bxSbMgszYxbCqDonF"
Meteor条目。查找({})
返回:

Entries
     Meteor.Collection {_makeNewID: function, _transform: null, _manager: Meteor._LivedataConnection, _collection: LocalCollection, _name: "entries"…}
    _collection: LocalCollection
    _savedOriginals: null
    docs: Object
        Wkxxpapm8bbiq59ig:
            _id: "M3vDJNMZJjBDfrc7D"
        bxSbMgszYxbCqDonF:
            _id: "bxSbMgszYxbCqDonF"
在模板函数中执行代码:

starredPages = user.profile.starredPages
starred =  Entries.find({ _id :{in: starredPages}}).fetch()
starred
返回为空白数组,即使starredPages数组中的
bxSbMgszYxbCqDonF
值与
Entries.docs
集合数组中的
\u id
值匹配


这是为什么?如何使它返回
星号页面
数组和
\u id
之间的匹配?

您需要使用
$in

starred =  Entries.find({ _id :{$in: starredPages}}).fetch()
简单打字;)