0

mapReduce から入力されたモデルに適用される正規表現に応じてドキュメントを取得する必要がありますが、それを達成できません。

Article.authors(function(err, model){
  model.find({ '_id.surname': /^A/ })
       .populate({ path: '_id', model: 'Author' })
       .exec(function(err, authors){
         ...
       });
});

手伝って頂けますか?上記は私に何も示していません...

4

2 に答える 2

0

キー _id.surname が必要ですか。姓のフィールドだけを実際に探しているのではないでしょうか? だからそうあるべきだ

Article.authors(function(err, model){
  model.find({ 'surname': /^A/ })
     .populate({ path: '_id', model: 'Author' })
     .exec(function(err, authors){
       ...
     });
});
于 2013-08-13T11:49:08.947 に答える
0

このようなもの:

model.find( { '_id.surname': new RegExp('^A') } )
     .populate({ path: '_id', model: 'Author' })
     .exec(function(err, authors){
       ...
     });

ここでの主要部分/^A/は、MongoDB シェル固有の構文であり、JavaScript では を使用する必要がありますnew RegExp('^A')

于 2013-08-07T08:51:37.650 に答える