Closed
Bug 690077
Opened 13 years ago
Closed 12 years ago
IDBCursor.PREV don't return duplicated entries
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: tobiasette, Unassigned)
Details
This code is like https://developer.mozilla.org/en/IndexedDB/Using_IndexedDB parametro1 = IDBKeyRange.lowerBound('string'); objetoStore = banco.transaction(['pessoas']).objectStore(['pessoas']); indice = objetoStore.index('nome'); indice.openCursor(parametro1,IDBCursor.PREV).onsuccess = function(evento) { cursor = evento.target.result; if (cursor) { //code cursor.continue(); } else { // code } }; IDBCursor.PREV not return duplicate entries, but in documentation[0] return all entries. [0] http://www.w3.org/TR/IndexedDB/#cursor-sync
Comment 1•12 years ago
|
||
Same problem here! Below code works fine in Chrome. But in Firefox 9.0.1 sometimes IDBCursor.PREV behaves the same as IDBCursor.PREV_NO_DUPLICATE and sometimes ignores all duplicate values: function initiate(){ databox=document.getElementById('databox'); var button=document.getElementById('save'); button.addEventListener('click',addobject,false); if('webkitIndexedDB' in window){ window.indexedDB=window.webkitIndexedDB; window.IDBTransaction=window.webkitIDBTransaction; window.IDBKeyRange=window.IDBKeyRange; window.IDBCursor=window.webkitIDBCursor; }else if('mozIndexedDB' in window){ window.indexedDB=window.mozIndexedDB; } var request=indexedDB.open('mydatabase'); request.addEventListener('error',showerror,false); request.addEventListener('success',start,false); } function showerror(e){ alert('Error:'+e.code+''+e.message); } function start(e){ db=e.result || e.target.result; if(db.version==''){ var request=db.setVersion('1.0'); request.addEventListener('error',showerror,false); request.addEventListener('success',createdb,false); } else { show(); } } function createdb(){ var objectstore=db.createObjectStore('movies',{keyPath:'id'}); objectstore.createIndex('SearchYear','date',{unique:false}); } function addobject(){ var keyword=document.getElementById('keyword').value; var title=document.getElementById('text').value; var year=document.getElementById('year').value; var transaction=db.transaction(['movies'],IDBTransaction.READ_WRITE); var objectstore=transaction.objectStore('movies'); var request=objectstore.add({id:keyword,name:title,date:year}); request.addEventListener('success',show ,false); request.addEventListener('error',showerror,false); document.getElementById('keyword').value=''; document.getElementById('text').value=''; document.getElementById('year').value=''; } function show(){ databox.innerHTML=''; var transaction=db.transaction(['movies']); var objectstore=transaction.objectStore('movies'); var index=objectstore.index('SearchYear'); var newcursor=index.openCursor(null, IDBCursor.PREV); newcursor.addEventListener('success',showlist,false); newcursor.addEventListener('error',showerror,false); } function showlist(e){ var cursor=e.result || e.target.result; if(cursor){ databox.innerHTML+='<div>'+cursor.value.id+' - '+cursor.value.name+' - '+cursor.value.date+ '</div>'; cursor.continue(); } } window.addEventListener('load',initiate,false);
Comment 2•12 years ago
|
||
I just tried the same code in FF 10.0 BETA... The problem doesn't exist anymore
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → WORKSFORME
Assignee | ||
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•