sql >> Base de Datos >  >> NoSQL >> MongoDB

Uso de Async con MongoDb para completar documentos de colección en orden

su insertRowInBLD la función tiene que devolver una Promise instancia en lugar de undefined como ahora. Async.series se le pasa una matriz de undefined .

Esto.

function fillBLD() {
    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', '', '', '', ''),
        ]
    );
}

es en realidad esto.

function fillBLD() {
    async.series(
        [
            undefined,
            undefined,
            undefined,
            undefined,
            undefined
        ]
    );
}