Concept: I want my MongoDB document to be updated with new encryption. for this I am using traverse library npm which iterate over Every object key: pair now problem arises when is mark Traverse(Object).each(async(__data) <-- if is use async-await Than traverse will start skipping data return from __data.i also tried BlueBird for promise. resolve but it splitted all data into individual character set.
Question I want async functionality inside traverse.each method so that any data change happen inside traverse will be asyncronus.
Code
// if given @_dataType is not empty.
await FindAndReplace(_dataPipe).forEach((data) => {
// local variable.
let _hash
console.log('13-043')
console.log(TypeCheck('Object', data) && _.keys(data).indexOf(_allowedHash[m]) > -1, data, _allowedHash[m])
// if current key is allowed.
if (TypeCheck('Object', data) && _.keys(data).indexOf(_allowedHash[m]) > -1) {
// Argon2 data.
BlueBird.method(__Argon2.hash([data[_allowedHash[m]]]), __hash => {
// concat hash result.
_hash += __hash
})
console.log('-1304')
console.log(_hash, TypeCheck('String', _hash), data[_allowedHash[m]])
// on successful data encoding.
if (TypeCheck('String', _hash)) {
data[_allowedHash[m]] = _hash
data['encryption'] = {
'Argon2': {
'for': _allowedHash[m],
'hash': _hash
}
}
// emmit data for allowing validation.
_emmit('Argon2', Argon2)
// style guide.
Context.debug(`data encoded successfully with argon2..`, 'successful')
}
}
})
NOTE if I am not clean Than let me know what else I can provide you. so that you call tell me exaclty why it is not working. and how will it work?
Thanks