fix nested mongo id as $oid #387

This commit is contained in:
Jan Prochazka 2022-10-08 09:00:19 +02:00
parent 23cb3a4b12
commit 2a2debbb88

View File

@ -9,7 +9,9 @@ const AbstractCursor = require('mongodb').AbstractCursor;
const createBulkInsertStream = require('./createBulkInsertStream');
function transformMongoData(row) {
return _.mapValues(row, (v) => (v && v.constructor == ObjectId ? { $oid: v.toString() } : v));
return _.cloneDeepWith(row, (x) => {
if (x && x.constructor == ObjectId) return { $oid: x.toString() };
});
}
async function readCursor(cursor, options) {