这段代码中的大部分内容都可以正常工作。除了最后的 sqlcalls。
完整代码:
<!doctype html>
<html><head>
<meta charset="UTF-8">
<script type = "text/javascript" src="jquery-1.11.0.js"></script>
<script type = "text/javascript" src="ydn.db-iswu-sql-e-dev.js"></script>
</head><body><script type = "text/javascript">
//ydn.db.deleteDatabase('BibleWay');
var context_bible_schema = {
name: 'context',
keyPath: 'vsid',
autoIncrement: true,
indexes: [
{
name: 'bid',
keyPath: 'bid',
unique: false,
multiEntry: false
}, {
name: 'bk',
keyPath: 'bk',
unique: false,
multiEntry: false
} , {
name: 'c',
keyPath: 'c',
unique: false,
multiEntry: false
} , {
name: 'v',
keyPath: 'v',
unique: false,
multiEntry: false
}
]
};
schema = {
stores: [context_bible_schema]
};
var db = new ydn.db.Storage('BibleWay',schema);
function downloadBible() {
var i2=0;
$.getJSON("http://bibleway.us/api/js/3.json", function(data){
$.each(data, function( index, value ) {
// bible id [bid]
var split_bid=index;
$.each(value, function( index, value ) {
// bible book name
console.log(index);
var split_bk=index;
$.each(value, function( index, value ) {
// bible book chapter
var split_c=index;
$.each(value, function( index, value ) {
$doadd=new Object();
$doadd.bid=split_bid;
$doadd.bk=split_bk;
$doadd.c=split_c;
$doadd.v=index;
$doadd.t=value;
db.put('context',$doadd);
++i2;
})
})
})
});
showshv();
}
);
}
function showshv() {
db.getSchema(function(schema) {
console.log(schema);
});
req = db.get('context', 2050);
req.done(function(record) {
console.log(record);
});
req.fail(function(e) {
throw e;
});
db.from('context').select('bk').unique(true).list().done(function(hobby) {
console.log(hobby);
});
}
db.from('context').select('bk').unique(true).list().done(function(hobby) {
if (hobby[0] === undefined) {
downloadBible();
}else{
showshv();
}
});
document.write('hey<br>');
db.executeSql('SELECT * FROM context WHERE bid=\'3\' and bk = \'GEN\' AND c=\'50\'').then(function(results) {
document.write(results);
}, function(e) {
throw e;
});
db.executeSql('SELECT MAX(c) FROM context').then(function(results) {
console.log(results);
}, function(e) {
throw e;
});
</script></body></html>
我得到的错误是底部的最后两个“db.executeSql”。
未捕获的 ydn.error.NotSupportedException:条件太多。对于“where”子句。
这有什么用。indexeddb 是否有任何允许多个条件的包装器?
谢谢