1

我刚刚开始使用 Lawnchair 的查询插件,我似乎无法让查询语法与 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 单元测试来做的。

4

0 回答 0