コレクションにはこのようなデータが含まれています
{
'_id': ObjectId("527cf8ae3ad5a461caf925fc"),
'name': {
'first': 'John',
'last': 'Backus'
}
}
$where で「John」という名のレコードを検索したい
$m = new MongoClient();
$db = $m->selectDB('school');
$collection = new MongoCollection($db, 'student');
$js = "function() {
return this.first.name == 'John';
}";
$cursor = $collection->find(array('$where' => $js));
例外が発生しています Caught exception: localhost:27017: TypeError: Cannot read property 'first' of undefined near 'this.name.first=='Jo'
$whereだけで検索したい。