Tuesday 11 April 2017

Sails js callback function

I'm pretty new with the whole callback and promises stuff, honestly speaking I don't know how it works internally and currently I'm working with sails and found myself in a problem, I have in my database person and student, when someone tries to create a student the person must be created first, but the method to do so is in another controller, I can call the method in the other controller using sails.controller.person.create() but, how do I make it so that it waits from a response from create before continuing? or there's no need for it and the function who called create from person will wait for a return?

NOTE: it's obvious but I'm planing to make a create on the database on the create method which is asynchronous that's what got me confused whether it'll wait for the return inside of the query's callback or not.



via Baek Ryun

No comments:

Post a Comment