I've created many promises like that, in order to create object in my database.
var createUserPromise = new Promise(
function(resolve, reject) {
User.create({
email: 'toto@toto.com'
}, function() {
console.log("User populated"); // callback called when user is created
resolve();
});
}
);
At the end, I want call all my promises in the order I want. (because somes object depend of other, so I need to keep that order)
createUserPromise
.then(createCommentPromise
.then(createGamePromise
.then(createRoomPromise)));
So I expect to see :
User populated
Comment populated
Game populated
Room populated
Unfortunately, this messages are shuffled and I don't understand what.
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…