Question

Mostly everything in this code do work; except the last sqlcalls.

Full code:

<!doctype html>
<html><head>
    <meta charset="UTF-8">
<script type = "text/javascript" src="jquery-1.11.0.js"></script>
<script type = "text/javascript" src="ydn.db-iswu-sql-e-dev.js"></script>
</head><body><script type = "text/javascript">
//ydn.db.deleteDatabase('BibleWay');
var context_bible_schema = {
  name: 'context',
  keyPath: 'vsid',
  autoIncrement: true,
  indexes: [
    {
      name: 'bid',
      keyPath: 'bid',
      unique: false,
      multiEntry: false
    }, {
      name: 'bk',
      keyPath: 'bk',
      unique: false,
      multiEntry: false
    } , {
      name: 'c',
      keyPath: 'c',
      unique: false,
      multiEntry: false
    } , {
      name: 'v',
      keyPath: 'v',
      unique: false,
      multiEntry: false
    }
  ]
};
schema = {
  stores: [context_bible_schema]
};
var db = new ydn.db.Storage('BibleWay',schema);
function downloadBible() {
    var i2=0;
    $.getJSON("http://bibleway.us/api/js/3.json", function(data){
        $.each(data, function( index, value ) {
            // bible id [bid]
            var split_bid=index;
            $.each(value, function( index, value ) {
                // bible book name
                console.log(index);
                var split_bk=index;
                  $.each(value, function( index, value ) {
                    // bible book chapter
                    var split_c=index;
                    $.each(value, function( index, value ) {

                        $doadd=new Object();
                        $doadd.bid=split_bid;
                        $doadd.bk=split_bk;
                        $doadd.c=split_c;
                        $doadd.v=index;
                        $doadd.t=value;
                        db.put('context',$doadd);
                        ++i2;
                    })

                  })
            })
        });
        showshv();
        }
    );
}
function showshv() {
    db.getSchema(function(schema) {
      console.log(schema);
    });
    req = db.get('context', 2050);
    req.done(function(record) {
      console.log(record);
    });
    req.fail(function(e) {
      throw e;
    });
    db.from('context').select('bk').unique(true).list().done(function(hobby) {
        console.log(hobby);
    });
}


db.from('context').select('bk').unique(true).list().done(function(hobby) {
  if (hobby[0] === undefined) {
    downloadBible();
  }else{
    showshv();
  }
});
document.write('hey<br>');
db.executeSql('SELECT * FROM context WHERE bid=\'3\' and bk = \'GEN\' AND c=\'50\'').then(function(results) {

  document.write(results);

}, function(e) {
  throw e;
});

db.executeSql('SELECT MAX(c) FROM context').then(function(results) {
  console.log(results);
}, function(e) {
  throw e;
});
</script></body></html>

What I get the error on is the last two "db.executeSql" on the bottom.

Uncaught ydn.error.NotSupportedException: too many conditions. for the "where" clause.

What's the use of this. Is there any wrapper for indexeddb that would allow multiple conditions?

Thank you

Was it helpful?

Solution

It is not supported in executeSql, but I can join manually as describe here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top