동일한 indexeddb에 두 개의 서로 다른 객체 저장소가있는 경우 문제는 모든 저장소에서 기본 키 값이 "공유"된 것처럼 보입니다.IndexedDb의 iOS8 구현에 대한 주요한 주요 문제
<body>
<script type="text/javascript">
//prefixes of implementation that we want to test
window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
//prefixes of window.IDB objects
window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction;
window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange
if (!window.indexedDB) {
window.alert("Your browser doesn't support a stable version of IndexedDB.")
}
var db;
var request = window.indexedDB.open("newDatabase", 4);
request.onerror = function(event) {
console.log("error: ");
};
request.onsuccess = function(event) {
db = request.result;
console.log("success: "+ db);
};
request.onupgradeneeded = function(event) {
var db = event.target.result;
var objectStore = db.createObjectStore("customers", {keyPath: "arseid"});
var objectStore = db.createObjectStore("test", {keyPath: "id"});
}
function add1() {
var x = new Date();
var h1 = x.getHours();
var m1 = x.getMinutes();
var s1 = x.getSeconds();
console.log('starting insert on ' + h1 + ':' + m1 + ':' + s1);
var tx = db.transaction(["customers"], "readwrite");
for (var i = 0; i < 1000; i++) {
var request = tx.objectStore("customers")
.put({ arseid: i, name: "Jonathan Smith", email: "[email protected]", favourite: "chocolate cake", pet: "rudolph the red nose reindeer", address: "999 letsbe avenue, townton, countyshire" });
}
tx.oncomplete = function (e) {
// Re-render all the todo's
var x2 = new Date();
var h2 = x2.getHours();
var m2 = x2.getMinutes();
var s2 = x2.getSeconds();
console.log('transaction complete ' + h2 + ':' + m2 + ':' + s2);
}
}
function add2() {
//tx 2
var tx2 = db.transaction(["test"], "readwrite");
for (var i = 0; i < 1000; i++) {
var request2 = tx2.objectStore("test")
.put({ id: i, name: "Robwin Mwengway", email: "[email protected]", favourite: "chocolate cake", pet: "rudolph the red nose reindeer", address: "999 letsbe avenue, townton, countyshire" });
}
tx2.oncomplete = function (e) {
var x3 = new Date();
var h3 = x3.getHours();
var m3 = x3.getMinutes();
var s3 = x3.getSeconds();
console.log('transaction complete ' + h3 + ':' + m3 + ':' + s3);
}
}
</script>
<button onclick="add1()">Add1 data to indexedDb</button>
<button onclick="add2()">Add2 data to indexedDb</button>
</body>
(바이올린 : http://jsfiddle.net/jonnyknowsbest/4pdp8vxe/) 당신이 바이올린을 실행하고 "색인화에 ADD1 데이터"를 클릭하면 iOS8의에서
는 다음 1000 항목은 "고객"테이블에 추가됩니다. "Added to data to IndexedDb"를 클릭하면 1000 개의 항목이 "공급 업체"테이블에 추가되지만 "customers"의 1000은 제거됩니다.
누구도이 문제를 알고 있습니까? 이 부분은 IndexedDb 사양의 일부입니까? Chrome에이 문제가없는 것으로 보입니다.
편집 : 발견했습니다 W3 Org IndexedDB Recommendation : "동일한 키가있는 특정 개체 저장소에 여러 레코드가있을 수 없습니다." 애플은 데이터베이스 수준에서 이것을 적용한 것으로 보인다.
은 와우, 나쁜. 아직 iOS 8을 사용해 본 적이 없지만 iOS 8 기반의 iOS 기반 앱이 iOS 8에서 전혀 실행되지 않는다는 일부 사용자의보고가있었습니다. 나는 놀랍다 고 말할 수 없다. 내 음모 이론에 잘 들어 맞는다. http://stackoverflow.com/a/20110477/786644 :) – dumbmatter
Jeeze. autoIncreement를 지정하도록 지정해도 그것은 손상된 것 같습니다. –
으. 하나의 트랜잭션을 사용하여 문제를 해결하려고했습니다. 하나의 트랜잭션에서 N 개의 객체 저장소를 지정할 수 있습니다. 아니, 오류가 발생합니다. –