> On Mar 11, 2015, at 1:13 PM, Ersin Demirtas <[email protected]> 
> wrote:
> 
> I have following steps all in one function
> 
>         step 1 - input validation
>         step 2 - building db query for substring search
>         step 3 - query from db - adverts and users (uses the query build in 
> step 2) 1st query
>         step 4 - query from db - advert images (uses the results from step 3) 
> 2nd query
>         last step - output xml
> 
> { '@': { id: 'BR617' },
>   type: 'babysitter',
>   title: '',
>   description: 'Lorem Ipsum is simply dummy text of the printing and 
> typesetting industry. Lorem Ipsum has been the industry\'s standard dummy 
> text ever since the 1500s, when an unknown printer took a galley of type and 
> scrambled it to make a type specimen book. It has survived not only five 
> centuries, but also the leap into electronic typesetting, remaining 
> essentially unchanged. It was popularised in the 1960s with the release of 
> Letraset sheets containing Lorem Ipsum passages, and more recently with 
> desktop publishing software like Aldus PageMaker including versions of Lorem 
> Ipsum.',
>   price: 28,
>   postcode: 'SE9 6JY',
>   latitude: 51.458798,
>   longi
> 
> When I console.log(row) in step 3 the log is displayed after last step. 
> ---------------------
> 
> I tried using q to run like synchronize but step 3 console.log(row) is still 
> displayed after last step. 
> 


My guess is that your issue likes in the way you are using Q/promises. A query 
from a DB is typically an asynchronous operation, so while step 3 is waiting on 
a response step 4 will run, and when that is waiting for a response, the last 
step will be executed. Using Q will indeed help you make them run in sequence. 
If you can can share the relevant code we can try to figure out what’s off.

        —ravi


-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/67368413-7E7C-4282-96D0-C2CD84D106C7%40g8o.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to