javascript - Run multiple MSSQL queries in node.js -


I am trying to run multiple SQL queries.

The problem is that the variable possibilities are going out of the fire and the forgotten node. Because of the use of JS. I am trying to work to wait for to do something like the keyword C #.

Here's my broken code; It should clarify what is trying to achieve:

  function getTopicsForMessages (request, result) {// Get topic for this message var queryString = "SELECT ripple_messenger.TopicTypes. Name, ripple_messenger.TopicTypes.imageUri "; QueryString + = "Ripple_messenger.TopicTypes from Ripple_Messer. MessageType JO"; QueryString + = "On (Rhapsody_MessengerMessageType.PatIkID = Ripple_messar.tapicTaps.id)"; QueryString + = "WHERE messageId =?"; (Var i = 0; i & lt; results.length; i ++) {mssql.query (queryString, [result [i] .ID], {success: work (subjects) results {results} [i] . Topic = topics; result;}, error: function (error) {console.error ("SQL read error:" + mistake); request reply. (Reside. INTERNAL_SERVER_ERROR, "failed to read SQL query")}}) ; } // Continue ... Once all the questions have been successfully implemented. }   

I think that it does not know just the way to do things node.

I've read about some packages / options for nodes. JS, like the keywords waiting for things, but I'm not sure if I'm using them Azure Mobile Services, I would be able to use them.

I'm pretty sure that I can do it in any way better query in SQL but again, I'm not quite sure how.

Many thanks in advance,

Danny

below The given code shows a potential implementation. Since all DB calls in node.js are asynchronous, if you run them in the "routine" loop, then you will send all calls to DB at the same time, and this can lead to some quota. (By waiting for a call to complete the next call). You can send some questions in parallel (are shown similar to batching techniques).

  function getTopicsForMessages (request, result) {// Get topic for this message var queryString = "selection ripple_messenger.TopicTypes.name, ripple_messenger.TopicTypes.imageUri"; QueryString + = "Ripple_messenger.TopicTypes from Ripple_Messer. MessageType JO"; QueryString + = "On (RApple_MessengerMessageTesticksTesticID = Ripple_MessengerTyricsType."); QueryString + = "WHERE messageId =?"; Var queryNextItem = function (i) {if (i> = results.length) {// All full continuity (); } Else {mssql.query (queryString, [results [i] .id], {success: function (topicsResults) {results [i] .topics = topicsResults; queryNextItem (i + 1);}, error: function (mistake) {Console.error ("SQL read error:" + mistake); request.respond (statusCodes.INTERNAL_SERVER_ERROR, "failed to read SQL query");}}); }} QueryNextItem (0); Function continuity () {// Continue ... Once all the questions have been successfully executed}}    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -