我刚刚开始使用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');
});
我相信我按照Lawnchair unit tests这样做。