Synchronous JSON ?
See original GitHub issueHi,
Bravo and Thanks for this amazing project - I really like the concept and I’m testing it to give our web application a new architecture.
To take an analogy with the classical Orders example:
- I’d like to json-query table “Orders” from the server,
- as “Products” and “ProductCategories” don’t change much, I’d like to load them once on initialisation, then JOIN on them with “Orders” (those quasi-static data may be updated later via a webworker polling for changes or a websocket).
So far the POC works well, I load data with something like:
var db = new alasql.Database("localdb");
alasql("USE DATABASE localdb");
dataAdrr = "http://server/query.php?object=Products";
dataQuery = 'SELECT * FROM JSON("' + dataAddr + '")';
alasql(dataQuery,[],function(data) {
db.exec('CREATE TABLE Products');
db.tables.Products.data = data;
});
but now I face the problem of asynchronicity of JSON :
console.table (alasql("SELECT * from Products")
returns nothing, as the data are not yet received…
The POC should show if we can load about 20 such tables, and perform locally the complex queries with multiple JOINS, subselects, groups… which we currently have on the php server.
If the POC succeeds, we’ll probably use Promises, Then, Resolve… to handle this asynchronicity, but is there is trick I can use right now to run JSON queries synchronously, something like “async: false” in previous jQuery versions ?
Thanks in advance !
Issue Analytics
- State:
- Created 9 years ago
- Comments:17 (11 by maintainers)
Now you can use it with promises:
Thank you for being persistent and keep getting inputs about the issue.
In the moment im running Chrome 41. I am not able to upgrade on this computer - but will try to run with 43 when I get back to my home computer