axemclion / jquery-indexeddb

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

getAll() and openCursor isn't working in my code #18

Closed bmshekhar closed 11 years ago

bmshekhar commented 11 years ago

Hi All,

I have used jQuery Indexeddb plugin, I have the latest version of Chrome installed. When i use the methods such as getAll() and openCursor, it throws an error as below Uncaught TypeError: Object # has no method 'getAll'

Please find the code which i have used below function searchDefect(defectIndex){ var defectData= $.indexedDB("Defect_Tracker").objectStore("Defect_Log").index(defectIndex).openCursor().each(function(elem){ alert('Inside'); });

}

function getAllData(table){ alert('function called'); var objectStore = $.indexedDB("Defect_Tracker").objectStore("Defect_Log").getAll(); }

Kindly help i'm in the middle of development

axemclion commented 11 years ago

Looking into this now.

scott-davidjones commented 11 years ago

i can confirm I'm also getting this; however trying

$.indexedDB("atlas").objectStore("Company").index("ID").each(function(i){
        console.log(i.value.Name);
    })

works - but using the above i get duplicate data..

rmobis commented 11 years ago

Most of the suite case tests also fail in my Dev Chrome build, with the same Uncaught TypeError

axemclion commented 11 years ago

@bmshekhar - Looks like you are using the older version of the library - I have updated the API in the library to make is simpler. The library does not require a user to understand openCursor and iterations are simpler using each. Similarly, the getAll method is no longer supported since the amount of data returned could be huge, and the specification is also favoring not supporting it.

@arazmus - I ran these 2 queryies on http://nparashuram.com/jquery-indexeddb/test/ page (Chrome Version 23.0.1271.64), and they seem to run fine

$.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE_1).each(function(elem){console.log(elem)})

$.indexedDB(DB.NAME).objectStore(DB.OBJECT_STORE1).index(DB.INDEX1_ON_OBJECT_STORE_1).each(function(){console.log(arguments)})

Adding that test page since the database is already created and seeded with data, would be easier for discussions. If you are still seeing the issue, can you please let me know if you are still seeing errors around that ? Since the defination of the object stores will help, it would be easier if we have a jsFiddle for this issue. If you still see the issue, can you open a new one, so that we can debug it there, with all relevant data ?

@rmobis I am able to reproduce the issue on Chome - Version 25.0.1334.0 canary. I have opened a new issue for this, and am looking at fixing it. Thank you for reporting the issue. Tracking the issue at https://github.com/axemclion/jquery-indexeddb/issues/21.

Closing this issue, please reopen if you still find the bugs.

scott-davidjones commented 11 years ago

@axemclion I think you miss read - i said that code worked :) but the openCursor didnt work - but you explained why that didnt work above :)

axemclion commented 11 years ago

@arazmus Yeah, I mis-read, my bad. I am also adding an interface document file so that the interface for the plugin is clearer

@rmobis Fixed the canary issue in 202e05cd3bf8374ff6956fef1d427c571040d176

bmshekhar commented 11 years ago

@axemclion i m using the latest version of indexeddb jquery, still its not working

axemclion commented 11 years ago

@bmshekhar The latest version of IndexedDB jquery does not support openCursor or getAll. The documentation for the API is here - https://github.com/axemclion/jquery-indexeddb/tree/master/docs

bmshekhar commented 11 years ago

@axemclion thank you parashuram for the update. Can you suggest me how to search the values without openCursor method and specify the range. Also without jquery we have transaction.abort. How can we use this in jquery. Please help

axemclion commented 11 years ago

@bmshekhar Here is the documentation for using cursors

https://github.com/axemclion/jquery-indexeddb/blob/gh-pages/docs/README.md#cursorEach

In short, its objectStore.each(function(item){/*Use the item*/}, range, direction)

The range is of the form [lower_limit, upper_limit, can_include_lower, can_include_upper]