filer/examples/deferred-test.html

87 lines
1.5 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<div id="stdout"></div>
</body>
<script src='../lib/require.js'></script>
<script>
require.config({
baseUrl: "../lib",
paths: {
"src": "../src"
}
});
require(["src/indexeddb2"], function(idb) {
var opened = idb.open('test').then(
function(event) {
return event.db;
},
function(event) {
console.error('error:', event);
},
function(event) {
if('upgradeneeded' == event.type) {
db = event.target.result;
if(db.objectStoreNames.contains('FILES')) {
db.deleteObjectStore('FILES');
}
var files = db.createObjectStore('FILES');
}
}
);
opened.then(
function(db) {
console.log(db);
}
);
/*
var db = idb.open('test');
db.progress(
function(event) {
if('upgradeneeded' == event.type) {
db = event.target.result;
if(db.objectStoreNames.contains('FILES')) {
db.deleteObjectStore('FILES');
}
var files = db.createObjectStore('FILES');
}
}
);
db.otherwise(
function(event) {
console.error('error:', event);
}
);
db.transaction(['FILES'], 'readwrite')(
function(transaction) {
var files = transaction.objectStore('FILES');
return files.clear();
}
).transaction(['FILES'], 'readonly')(
function(transaction) {
}
);
db.transaction(['FILES'], 'readwrite')(
function(transaction) {
}
);
*/
});
</script>
</html>