Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createIndex on an array property, each or eachKey with a range argument does not work #49

Open
guofengzh opened this issue Sep 10, 2013 · 0 comments

Comments

@guofengzh
Copy link

I modify the demo from https://bitbucket.org/axemclion/indexeddb-cordova-android.git to test how jquery-indexeddb index works on an array property.

I add the categories property ( of array type) to the catalog.json, like the following:

[{
    "itemId": 1001,
    "name": "Desktop",
    "description": "A normal looking desktop computer",
    "price": 100,
    "rating": 2,
    "categories":["x", "y"]

then i create the index on the categories property:

                            "1": function(versionTransaction){
                                var catalog = versionTransaction.createObjectStore("catalog", {
                                    "keyPath": "itemId"
                                });
                                catalog.createIndex("price");
                                catalog.createIndex("name");
                                catalog.createIndex("categories", {
                                          "unique" : false, 
                                          "multiEntry":true
                                       });
                            },

When catalog.json loaded into the db, I use the following to get the catalog items with a specific category:

                            console.log("Transaction completed, all data inserted");
                            loadFromDB("catalog");
                            // **** MY TEST CODE HERE
                            console.log("load by range") ;
                            _($.indexedDB("MyECommerceSite").objectStore("catalog").index('categories').eachKey(function(elem){
                                  console.log("RG:"+JSON.stringify(elem)) ;
                           },['a']));                           

Nothing printed on the console. Only Action complete printed (from the line number on the console, I know that the done() is invoked).

If I remove the range parameter ['a'], the expected result printed, for example:

09-10 13:08:28.346: I/Web Console(24010): RG:{"key":["a","b"],"value":1006} at file:///android_asset/www/index.html:163

What is wrong with my usage of the range parameter?

I run the App on a Android 4.2.2 mobile phone.

Thanks a lot.

Guofeng.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant