axemclion / jquery-indexeddb

An IndexedDB Plugin for Jquery.
Other
195 stars 71 forks source link

Recorde #59

Closed neerajjoshi closed 10 years ago

neerajjoshi commented 10 years ago

Hello Team

I am using the code to store client data locally can you please provide me an example how to read single data using key and update the record of that key.

Thanks

axemclion commented 10 years ago

Check out the examples folder/.

neerajjoshi commented 10 years ago

Hello Axemclion

I checked out the examples folder even the entire file structure https://github.com/axemclion/jquery-indexeddb/blob/master/example/index.html

but did not get any line which read data on the basis of key and update the record.

It will be good if you send a piece of code to read the data on the basis of a key and update it with new value in any field .

I am using the below code to read data and update it . Here i am using auto increment key and reading the value of 1 record and want to update it but it added a new record instead of updating it function updateDb() { var itid=1;
$.indexedDB("Customers").objectStore("catalog").get(itid).done(function(item){ var ary={uniqid:2000,id:1,name:'test',price:786}; $.indexedDB("Customers").objectStore("catalog").put(ary); });

2013-12-11_1052

}

I am also attaching the structure of my database . It is really urgent to update the record so it will be nice if you provide a sample piece of code .

neerajjoshi commented 10 years ago

Hello Team,

I using IndexedDBShim.min.js and jquery.indexeddb.js in project for storing client data on local storage . The add and show data is working fine but I am unable to apply cursor query on it . Below is my code in typical indexed db structure and I want it to change as per jquery.indexeddb.js. Please help me how to change it according to jquery.indexeddb.js wrapper.

var transaction = db.transaction(["users"], "readonly"); var objectStore = transaction.objectStore("users"); var index = objectStore.index("tags");

            var rangeTest = IDBKeyRange.only(tag);
            index.openCursor(rangeTest).onsuccess = function(e) {
            var cursor = e.target.result;
            if (cursor) 
            {
                s += "<h2>Key "+cursor.key+"</h2><p>";
                for(var field in cursor.value) {
                s+= field+"="+cursor.value[field]+"<br/>";
                }
                s+="</p>";
                cursor.continue();
            }

Thanks