-
Notifications
You must be signed in to change notification settings - Fork 51
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
Question regarding passing additional args #7
Comments
What's the relationship to the extra data? Is it tied in anyway to the data being pulled from the database? |
No. It's strictly ancillary data that needs to be tweaked based on the nSQL data. Just wondered if there might be a need for some pass-through data as an option. The main reason is because once you enter the promises for nSQL nothing outside the scope of nSQL is available even though it might be scoped inside a function that contains the nSQL calls. |
There's an undocumented property on the nSQL variable that can hold arbitrary data: nSQL().data = {something:"here"};
console.log(nSQL().data.something): // <- "here" The variable isn't used by the lib at all, so it's up to you to initialize it and use it how ever. Beyond that, since the data isn't related to the nSQL data it kind of makes sense to manage that outside of the nSQL store, just my two cents. |
Also, scope usually allows you to access parent scoped variables inside the promise. var globalVar = "yo".
nSQL("table").query("select").exec().then(function(rows, db) {
console.log(globalVar) // <- "yo"
}); There's a really good article on Medium that covers JS closures, might make this make more sense. |
ok, thanks a bunch |
I have a need to pass additional data (not in an nSQL table) to be used, for example, after a result is pulled using a query. I have the following example...
Is there a convenient way to pass additional data? Currently handling it by creating a function and calling it like:
The text was updated successfully, but these errors were encountered: