fixed mongoDB rename collection #1198

This commit is contained in:
SPRINX0\prochazka
2025-09-01 08:57:30 +02:00
parent 26cc15b4a2
commit 14e97cb24f

View File

@@ -167,21 +167,35 @@ const driver = {
case 'createCollection': case 'createCollection':
await this.script(dbhan, `db.createCollection('${operation.collection.name}')`); await this.script(dbhan, `db.createCollection('${operation.collection.name}')`);
break; break;
// case 'dropCollection':
// await this.script(dbhan, `db.getCollection('${operation.collection}').drop()`);
// break;
// case 'renameCollection':
// await this.script(
// dbhan,
// `db.getCollection('${operation.collection}').renameCollection('${operation.newName}')`
// );
// break;
// case 'cloneCollection':
// await this.script(
// dbhan,
// `db.getCollection('${operation.collection}').aggregate([{$out: '${operation.newName}'}]).toArray()`
// );
// break;
case 'dropCollection': case 'dropCollection':
await this.script(dbhan, `db.getCollection('${operation.collection}').drop()`); await this.script(dbhan, `db.dropCollection('${operation.collection}')`);
break; break;
case 'renameCollection': case 'renameCollection':
await this.script( await this.script(dbhan, `db.renameCollection('${operation.collection}', '${operation.newName}')`);
dbhan,
`db.getCollection('${operation.collection}').renameCollection('${operation.newName}')`
);
break; break;
case 'cloneCollection': case 'cloneCollection':
await this.script( await this.script(
dbhan, dbhan,
`db.getCollection('${operation.collection}').aggregate([{$out: '${operation.newName}'}]).toArray()` `db.collection('${operation.collection}').aggregate([{$out: '${operation.newName}'}]).toArray()`
); );
break; break;
default: default:
throw new Error(`Operation type ${type} not supported`); throw new Error(`Operation type ${type} not supported`);
} }