You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wondering if it is easier to initialise sql-stamp by loading all the files synchronously.
For example:
varsqlStamp=require("sql-stamp");// Make some templatesvartemplates=sqlStamp(["/path/to/sql"]);// This step sync// Use those templatesvarsql=templates("/path/to/sql",{one: "fish"});
The advantage of this is you could easily put the template loading part into a module and require it.
/sql-templates.js
varsqlStamp=require("sql-stamp");// Make some templatesmodule.exports=sqlStamp(["/path/to/sql"]);// This step sync
/model.js
vartemplates=require("./sql-templates");// Use those templatesvarsql=templates("/path/to/sql",{one: "fish"});// use sql
With async you need some kind of initialising step to ensure all the files are loaded.
/sql-templates.js
varsqlStamp=require("sql-stamp");// Make some templatesvartemplates;functioninit(){returnsqlStamp(["/path/to/sql"]).then(function(sql){templates=sql;returnsql;});}module.exports=function(){if(templates){returnPromise.resolve(templates);}else{returninit();}}
/model.js
vartemplates=require("./sql-templates");// Use those templatestemplates().then(function(templates){varsql=templates("/path/to/sql",{one: "fish"});// use sql});
As files are loaded once on app start it would seem there is no performance reason to load async and seems more cumbersome to use.
Hopefully I've missed some easy way to initialise.
The text was updated successfully, but these errors were encountered:
I'm wondering if it is easier to initialise sql-stamp by loading all the files synchronously.
For example:
The advantage of this is you could easily put the template loading part into a module and require it.
/sql-templates.js
/model.js
With async you need some kind of initialising step to ensure all the files are loaded.
/sql-templates.js
/model.js
As files are loaded once on app start it would seem there is no performance reason to load async and seems more cumbersome to use.
Hopefully I've missed some easy way to initialise.
The text was updated successfully, but these errors were encountered: