sql >> Databáze >  >> NoSQL >> MongoDB

Použití Async s MongoDb k vyplnění dokumentů sbírky v pořadí

váš insertRowInBLD funkce musí vrátit Promise instance namísto undefined právě teď. Async.series je předáváno pole undefined .

Toto.

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', '', '', '', ''),
        ]
    );
}

je vlastně toto.

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



  1. mongoose (mongodb) Pole Alias ​​_id

  2. Pymongo:insert_many + jedinečný index

  3. 4 způsoby aktualizace dokumentu v MongoDB

  4. Najděte dokumenty v MongoDB, jejichž pole pole je podmnožinou pole dotazů