brianleroux / lawnchair

A lightweight clientside JSON document store,
http://brianleroux.github.com/lawnchair
MIT License
2.14k stars 245 forks source link

Problem on first query to a table #34

Closed brafales closed 12 years ago

brafales commented 13 years ago

Hi, I'm developing an app that has to run on PhoneGap using both Android 2.x and iPhone 4.x I'm having a problem with iPhone in the first query of a table. I've been looking at the code and I see that when you create an object, it does a select to see if the table exists and if it does not it creates it. However, if you create a new Lawnchair object and just after that you try to query an object in that table for the first time, the query is actually done before the table check transaction fails, hence the table is created after the query is done, raising an error of "no such table". I guess I'll be able to work around this by using a timer, and I guess this will be hard to solve given the asynchronous nature of the WebKit SQL, but it's worth looking it.

Cheers!

joelnet commented 13 years ago

Your code should not run after your creation of the new lawnchair object, but inside the callback.

brianleroux commented 12 years ago

callbacks now required in 0.6.x