Environment: sequelize 3.27, node.js 6.1, express
sequelize
Object.hasMany(OtherObject)
I have the following piece of code:
//...
await db.Object.create(objectData).then(async (object:any) => {
//..
object.update({sharedLink: aUrl}); //no me interesa que sea secuencial
await request.othersObjects.forEach(async (otherObject:any) => {
const hr = await db.OtherObject.create(otherObject);
});
//aquí el problema
for(let oo of await db.OtherObject.findAll({attributes:['id'], where: {objectId: object.id}})) {}
}
My problem is that I do not have otherObjects with objectId = object.id when they should have ...
And it is because the create of the OtherObject occurs after the for for (let oo ...
Why? If I think I'm putting await in the right way?
As a comment, apparently now everything is going on putting
await object.update({sharedLink: aUrl});
although I do not care if this update is sequential.