Dexie.js: How to get count?

Created on 30 Dec 2016  Â·  3Comments  Â·  Source: dfahlander/Dexie.js

I have the following query,

// app.GAME_TYPE_BASIC => 1
var x = db.levels.where('type').equals(app.GAME_TYPE_BASIC);

return x.count();

The table setup can be seen below,

--------------------------
type | completed | level
--------------------------

using the above query there should be a count of 20. However in the console (where I am outputting) I get a object with all extra data.

question

Most helpful comment

Try this

var x = db.levels.where('type').equals(app.GAME_TYPE_BASIC);

return x.count().then (function(c){console.log (c)})

The count () call is async and you have to wait for it before calling console. In case you are already doing that then maybe you could post some more code to see if there could be other issues.

All 3 comments

What extra data? Are you using a promise to output the count in the console?

Below is part of it, it seems to me to be an error stack, however I checked the lines and nothing is occurring on those.

U {_listeners: Array[0], _lib: false, _PSD: Object, _stackHolder: Error
    at S (http://127.0.0.1/www/assets/js/core/dexie.js:1:4608)
    at new U (http://127…, _prev: U…}```

Line 6 is the return x.count();, so the query is failing?

Try this

var x = db.levels.where('type').equals(app.GAME_TYPE_BASIC);

return x.count().then (function(c){console.log (c)})

The count () call is async and you have to wait for it before calling console. In case you are already doing that then maybe you could post some more code to see if there could be other issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmlzj picture dmlzj  Â·  3Comments

ballabusta picture ballabusta  Â·  4Comments

ghost picture ghost  Â·  3Comments

kamleshchandnani picture kamleshchandnani  Â·  4Comments

asdip138 picture asdip138  Â·  3Comments