mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 04:16:00 +00:00
mogno export+import uses EJSON
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const ObjectId = require('mongodb').ObjectId;
|
||||
const { getLogger } = global.DBGATE_PACKAGES['dbgate-tools'];
|
||||
const { EJSON } = require('bson');
|
||||
|
||||
const logger = getLogger('mongoBulkInsert');
|
||||
|
||||
@@ -26,7 +27,7 @@ function createBulkInsertStream(driver, stream, pool, name, options) {
|
||||
...row,
|
||||
};
|
||||
}
|
||||
writable.buffer.push(row);
|
||||
writable.buffer.push(EJSON.deserialize(row));
|
||||
};
|
||||
|
||||
writable.checkStructure = async () => {
|
||||
|
||||
@@ -245,8 +245,23 @@ const driver = {
|
||||
const db = await getScriptableDb(pool);
|
||||
exprValue = func(db, ObjectId.createFromHexString);
|
||||
|
||||
const pass = new stream.PassThrough({
|
||||
objectMode: true,
|
||||
highWaterMark: 100,
|
||||
});
|
||||
|
||||
exprValue
|
||||
.forEach((row) => pass.write(transformMongoData(row)))
|
||||
.then(() => {
|
||||
pass.end();
|
||||
// pass.end(() => {
|
||||
// pass.emit('end');
|
||||
// })
|
||||
});
|
||||
|
||||
return pass;
|
||||
// return directly stream without header row
|
||||
return exprValue.stream();
|
||||
// return exprValue.stream();
|
||||
|
||||
// pass.write(structure || { __isDynamicStructure: true });
|
||||
// exprValue.on('data', (row) => pass.write(row));
|
||||
|
||||
Reference in New Issue
Block a user