Closed pito-svk closed 8 years ago
I have a problem with using node-orm in 'for loop':
for (let i = quantity - 1; i >= 0; i--) { FirstModel.create(firstModelData, (err, firstModel) => { if (err) { ... } secondModel.addFirstModel(firstModel, err) => { if (err) { ... } } }); }
I want to create arbitrary number of FirstModel items (works).
But, I want to assign each one to secondModel item. (doesn't work).
Problem is that for loop evaluates only last item and create references only to this last FirstModel item in loop.
Is there any way to solve this issue?
Thanks.
https://github.com/caolan/async
I have a problem with using node-orm in 'for loop':
I want to create arbitrary number of FirstModel items (works).
But, I want to assign each one to secondModel item. (doesn't work).
Problem is that for loop evaluates only last item and create references only to this last FirstModel item in loop.
Is there any way to solve this issue?
Thanks.