Using Async With Mongodb To Fill Collection Documents In Order
I decided to use Async module to populate a mongodb collection in the order that I want. Without Async the code works but the documents aren't inserted in the proper order: funct
Solution 1:
your insertRowInBLD
function has to return a Promise
instance instead of undefined
as now. Async.series
is being passed an array of undefined
.
This.
functionfillBLD() {
async.series(
[
insertRowInBLD('R01', 'Disclosure of data due to deliberate action by internal actor', 'E. Not significant', 'Partially effective', 'Low', '', '', '', ''),
insertRowInBLD('R02', 'Corruption of data due to deliberate action by internal actor', 'E. Not significant', 'Partially effective', 'Low', '', '', '', ''),
insertRowInBLD('R03', 'Unavailability of data due to deliberate action by internal actor', 'E. Not significant', 'Partially effective', '', '', '', '', ''),
insertRowInBLD('R04', 'Disclosure of data due to attack of the communications link by internal/external actor', 'E. Not significant', 'Partially effective', 'Low', '', '', '', ''),
insertRowInBLD('R05', 'Corruption of data due to attack of the communications link by internal/external actor', 'E. Not significant', 'Partially effective', 'Low', '', '', '', ''),
]
);
}
is actually this.
functionfillBLD() {
async.series(
[
undefined,
undefined,
undefined,
undefined,
undefined
]
);
}
Post a Comment for "Using Async With Mongodb To Fill Collection Documents In Order"