I work with the last beta version of Sails / Waterline for NodeJS, the association system isn't ready yet so i'm trying to find a way to populate datas from other models with a small trick.
For example, I got a "User" model which has many "Server", let's forget about waterline populate() which is for now quite bugued and find out how to do it manually in pseudo-code :
FIND USER THEN { // asynchronous
LOOP XXX
FIND (EACH) SERVER FROM ID { // asynchronous
DO THINGS HERE
}
END LOOP
THEN OUTPUT SOMETHING
}
I think you already understood the big problem i got. The "THEN OUTPUT SOMETHING" will output something before the loop is ended because it's asynchronous requests. I tried to check on async (with callbacks, but there's nowhere to put it here) or these kind of tools but it seems there is nothing to handle this typical case that will appear everywhere in my project ...
Any idea ? That's really a big problem for every project I could make in NodeJS and i'm sure i'm not alone in this case ...
Thanks ;)