我在 webkit-sqlite 适配器上遇到问题。它以某种方式保存key
字符串格式而不是整数。索引数据库工作得很好。它不会将密钥转换为字符串。请看下面的代码。
var ppl = Lawnchair({adapter: 'webkit-sqlite', name:'people', record:'person'}, function(people) {
// anon fn bound to the instance
this.save({key:1, id:1, a:1, name:'nino'}, function(obj){
console.log(obj);
});
// anon fn bound to the instance
this.save({key:'2', id:2, a:2, name:'paolo'}, function(obj){
console.log(obj);
});
// get all the keys
this.keys(function(keys) {
console.log('keys:', keys);
});
// get 1
this.get(1, function(key) {
console.log('key:', key);
});
// get '2'
this.get('2', function(key) {
console.log('key:', key);
});
// we can also clear the entire collection w/ nuke
this.nuke()
});
输出:
undefined
Object {key: 1, id: 1, a: 1, name: "nino"}
Object {key: "2", id: 2, a: 2, name: "paolo"}
keys: ["1.0", "2"]
key: undefined
key: Object {key: "2", id: 2, a: 2, name: "paolo"}
错误:
看keys: ["1.0", "2"]
应该是keys: [1, "2"]
有人有这个补丁吗?
谢谢。