0
MongoDB 1.8.1을 사용하고 있습니다. JavaScript 배열에 표준 some
메서드를 사용하여 $where
절 내에 Mongo의 $elemMatch
쿼리를 에뮬레이트하고 싶습니다. 그러나, 비록 내가 더미 함수를 제공하더라도, 쿼리는 결코 어떤 것도 매치하지 않습니다. 하여 MongoDB에서
> db.foo.insert({bar: [1, 2, 3]})
> db.foo.count({$where: 'this.bar && (this.bar.length > 0)'})
1
> db.foo.count({$where: 'this.bar && this.bar.some'})
1
> db.foo.count({$where: 'this.bar && this.bar.some(function() {return true;})'})
0
자체 쉘, 그것을 작동 :
> [1, 2, 3].some(function() {return true;})
true
는 왜입니까?