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

cand understand order of code running #115

Closed
boynet opened this issue Jun 28, 2015 · 1 comment
Closed

cand understand order of code running #115

boynet opened this issue Jun 28, 2015 · 1 comment

Comments

@boynet
Copy link

boynet commented Jun 28, 2015

just cant understand it, take this simple code:

db.games.put({vs: vs, score: score,why:why}).then (function(){
        db.scoreVS.where('vs').equals(vs).toArray(function(a) {
            return a;
        }).then(function (a) {
                console.log('1');
                db.scoreVS.put(a[0]).then(function(){
                    console.log('2');
                });
        });
        db.close();
    });

I excepeted to see in console:

1
2

while I see the reverse:

2
1

whats the right way of making a table with counter inside it and to increase the counters in some situations? right now I do where to get the counter value increase it and do a put with the new data. but its not working as the put working first and than the increasment

@dfahlander
Copy link
Collaborator

Sounds strange. I've no time to debug that right now, but one obvious issue with your code is that you close the database before everything is done. Move db.close() to after console.log('2').

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

2 participants