特定のテーブル内の特定のアイテムを検索し、YDN-DB を使用して目的の結果を返すことができる単純な関数を作成しようとしていますが、これまでのところ、次のようになっています。
var simpleSearch = function(table,field,string,limit,callback){
var look = db.from(table).where(field, '=', string).list(limit);
look.done(function(result) {
callback(true,result);
});
look.fail(function() {
callback(false,'');
});
}
//usage
simpleSearch('mytable','fieldname','nice field',1,function(found,result){
if(found){
console.log('item '+result.fieldname+' found'); //on success should output 'item nice field found'
}else{
console.log('nothing found');
}
});
問題は、このコードがまったく機能していないということです。私を助けてくれますか、どこが間違っているのか指摘してもらえますか?
前もって感謝します。