the all in 'hgetall' actually means getting all the properties of that
member, so for every member it reads the data in, trying out your
modification, the cb(null, 'lst') was called multiple times.

this is quite a interesting question:

members.forEach(function(member) {

})

cb(null, 'lst‘)

since forEach is a synchronous as you pointed out, cb got called at
end of the loop, that's what I was expecting, but when every iteration
also calls an asynchronous callback, that will be different as those
asynchronous calls in fact happens after the cb(null, 'lst'), how to
deal with this kind of situation?

the real use case is, I got a list, then I'd use the list to retrieve
the details and check if that details is applicable to certain
situation, once all check is done, cb(null, 'lst') is called.

any solution to this?



On Mar 20, 6:20 pm, Oliver Leics <oliver.le...@gmail.com> wrote:
> The "all" in "hgetall" makes me think it gives me a list.
> Maybe not what you did expect, because I assumed that rclient.hgetall
> gives all items to the callback, not only one item.
>
> exports.get_list = function ( cb) {
>   rclient.smembers("list", function(err, members) {
>     if(err) { return cb(err); }
>     if(members.length==0) return cb(null, 'lst');
>     members.forEach(function(member){
>       console.log(member)
>       rclient.hgetall(member, function(err, items) {
>         if(err) { return cb(err); }
>         console.log(items)
>         cb(null, 'lst');
>       })
>     })
>   })
>
>
>
>
>
>
>
> }

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
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 post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to