Lawnchair查询插件 - 未捕获的引用错误

时间:2012-12-20 22:01:17

标签: javascript lawnchair

我刚刚开始使用Lawnchair的Query插件,我似乎无法使用查询语法来处理where()子句中的参数化参数。

var store = new Lawnchair('store', function() {
});

store.nuke();

// save some data
store.batch([{a:"abc"},{a:2},{a:2},{a:"def"},{a:4}], function() {

});

// query (works)
store.where("record.a === 2", function(results) {
    alert('got ' + results.length + ' results');
});

// query (works)
store.where("record.a === 'abc'", function(results) {
    alert('got ' + results.length + ' results');
});


// Uncaught ReferenceError: abc is not defined
store.where("record.a === ?", 'abc', function(results) {
    alert('got ' + results.length + ' results');
});

// Works but does not return any results
store.where("record.a === ?", "'abc'", function(results) {
    alert('got ' + results.length + ' results');
});

jsFiddle

我相信我按照Lawnchair unit tests这样做。

0 个答案:

没有答案