MongoDB入門–eval()関数の使い方
サンプルコード:
var h1 = 8, h2=16;
var ctm = “(function() {\n"
+" var hh = this.createdAt.getHours();\n"
+" if (hh >= “+h1 + “&& hh <= “+h2
+" )\n"
+" return true;\n"
+"})";
console.log(ctm);
var resultobj = eval(ctm);
Resource.findOne({$where:resultobj,account:"xxxxxxx"},function(err,docs){
console.log(err,docs);
})