mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 07:56:01 +00:00
ability to create string mongo IDs when importing
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
const ObjectId = require('mongodb').ObjectId;
|
||||
|
||||
function createBulkInsertStream(driver, stream, pool, name, options) {
|
||||
const collectionName = name.pureName;
|
||||
const db = pool.__getDatabase();
|
||||
@@ -19,11 +21,17 @@ function createBulkInsertStream(driver, stream, pool, name, options) {
|
||||
)
|
||||
return;
|
||||
}
|
||||
if (options.createStringId) {
|
||||
row = {
|
||||
_id: new ObjectId().toString(),
|
||||
...row,
|
||||
}
|
||||
}
|
||||
writable.buffer.push(row);
|
||||
};
|
||||
|
||||
writable.checkStructure = async () => {
|
||||
if (options.dropIfExists || options.truncate) {
|
||||
if (options.dropIfExists) {
|
||||
console.log(`Dropping collection ${collectionName}`);
|
||||
await db.collection(collectionName).drop();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,9 @@ const driver = {
|
||||
? `mongodb://${user}:${password}@${server}:${port}`
|
||||
: `mongodb://${server}:${port}`;
|
||||
|
||||
const options = {};
|
||||
const options = {
|
||||
useUnifiedTopology: true,
|
||||
};
|
||||
if (ssl) {
|
||||
options.tls = true;
|
||||
options.tlsCAFile = ssl.ca;
|
||||
|
||||
Reference in New Issue
Block a user