This project has moved. For the latest updates, please go here.

Where filter's not working for me

Dec 21, 2012 at 5:14 PM

Hi. I'm able to use

 

db.linq.from("store").select().then();

 as well as 

db.linq.from("store").insert();

But

db.linq.from("store").where("id").greaterThan('1').select().then();

and

db.linq.from("store").where("id").equals('1').select().then();

don't work for me. Can you see what I'm doing wrong?

Feb 3, 2013 at 5:20 PM
Me neither, this code:
<!DOCTYPE html> 
<html> 
<head>
    <meta charset="utf-8">
    <meta http-equiv="cache-control" content="no-cache">
    <script src="Scripts/jquery-1.8.3.min.js"></script>
    <script src="Scripts/IndexedDBShim.min.js"></script>
    <script src="Scripts/Linq2IndexedDB.js"></script>

<script>
    $(function(){
        var dbConfig = { version: 1 }
        dbConfig.definition = [
        {
            version: 1,
            objectStores: [
                { name: 'Account', objectStoreOptions: { autoIncrement: false, keyPath: "email" } },
            ],
            indexes: [{ objectStoreName: 'Account', propertyName: "email", indexOptions: { unique: true, multirow: false } }],
            defaultData: [
            ]
        }
        ];

        var db = window.linq2indexedDB("indexeddbtest", dbConfig);

        db.linq.from('Account').update({ email: 'my@email.com', passwordhash: 'xxx' }).then(function(e){
            console.log('updated/inserted record: ' + JSON.stringify(e));
            db.linq.from('Account').get('my@email.com').then(function(args){ alert('get returned: ' + args); });
            db.linq.from('Account').select().then(function(args){ alert('select returned: ' + args); });
        }, function(e){
            alert('error: ' + e);
        }); 
    });
</script>
</head>
<body>
    IndexedDB test with linq2indexedDB
</body>
</html>
The code line "db.linq.from('Account').select() ...." gives results in the following errors in the javascript console (with or without the IndexedDB polyfill):
Chrome (build 24.0.1312.57) :
GET http://localhost/Scripts/Linq2IndexedDB.js 404 (Not Found)
Internet Explorer (v9.0.8112):
SCRIPT5007: Unable to set value of the property 'json': object is null or undefined
Linq2IndexedDB.js, line 1391 character 9
SCRIPT5007: Unable to get value of the property 'transactionTypes': object is null or undefined
Linq2IndexedDB.js, line 356 character 13
Am I doing something wrong or is there a bug in the linq2indexeddb library?
Coordinator
Feb 4, 2013 at 6:26 AM
Hi,

I have a clue about what the issue may be. If I look at the error in chrome, he is looking for the worker file. The linq2indexeddb file is his own worker file. (This is necessary if you want to have background task). Because I didn't want an extra file to be added, I hosted this in the same file.

For this I needed to provide the location for the worker file. (you can find this by searching for ""). If you change this location to the absolute path from the root to the linq2indexeddb file, this should be solved. Example:
linq2indexedDBWorkerFileLocation= "/myrootfolder/Scripts/linq2indexeddb.js"
I think that is the issue, you can also change it outside my file. You just need to change it before starting to use the linq2indexeddb:
linq2indexedDB.prototype.utilities.linq2indexedDBWorkerFileLocation= "/myrootfolder/Scripts/linq2indexeddb.js"
Hope this helps.

For IE9 .... you don't have indexeddb there except if you installed it from http://html5labs.com . But I wouldn't advice you to use this one because no users will have it + it has a hugh gap with the specs. Upgrade to IE10 (is now in beta for win 7) is my advice.

greetings
Feb 4, 2013 at 6:09 PM
Edited Feb 4, 2013 at 6:23 PM
Adding
linq2indexedDB.prototype.utilities.linq2indexedDBWorkerFileLocation= "Scripts/Linq2IndexedDB.js"
right after the script tag solves it indeed.

I don't know about web workers yet, I will dive into it. I reccommend to put this instruction on the documentation page.
Thanks for your answer anyway!

Greetings,
Gerard Alberts

ps. forgot: IE SUX!