Re: [persistence.js] Returning the wrong type

24 views
Skip to first unread message

Jake Mumm

unread,
Sep 6, 2012, 12:57:35 AM9/6/12
to persis...@googlegroups.com
Can you share a bit of code so we can see your sequence of operations? That would make this a lot easier to understand what might be happening.

On Wed, Sep 5, 2012 at 3:29 PM, Jason Gray <jason.a...@gmail.com> wrote:
I have many tables that I am connecting to in quick succession, but when I grab the object type and do a query, sometimes persistence will return the wrong __type when using the list() function on a websql/sql/sqlite implementation of persistence.

Do I have to flush() before qeuring? How can I ensure I am getting the right type back?

Thanks.

Jake Mumm

unread,
Sep 6, 2012, 11:09:34 AM9/6/12
to persis...@googlegroups.com

Try:

 persistence.schemaSync(persistence.flush(function(){ 
    // your code to populate or do whatever 
}));

You have to make sure schemaSync and flush are done before proceeding, hence waiting for the flush callback.

On Sep 6, 2012 10:34 AM, "Jason Gray" <jason.a...@gmail.com> wrote:
As you wish: https://gist.github.com/3656872

It appears to be a race condition. If it truly is, what do you suggest the best way to go about avoiding this?
Reply all
Reply to author
Forward
0 new messages