我有一个包含以下条目的集合
{
"_id" : "6z2pQDYozQxEyPZYv",
"userId" : "b2dQ6SuPrwmPsLsg8",
"communicatingWith" : [ "KMT74bWPoZxDSKdrx", "KMT74bWPoZxDSKdrx" ]
}
当我通过流星查询mongo的字段communicationWith时,如果我做一个console.log(communicatingWith)
,输出是
[ 'KMT74bWPoZxDSKdrx', 'KMT74bWPoZxDSKdrx' ]
。
即使我这样做console.log(communicatingWith.length)
,输出也是 2
但是当我这样做时
communicatingWith.each(function(item){console.log(item)})
它抛出错误说
Exception while invoking method 'createPrivateMsgHanger' TypeError: Object KMT74bWPoZxDSKdrx,KMT74bWPoZxDSKdrx has no method 'each'
你能帮我理解哪里出了问题吗?