renameCollection, cloneCollection - in driver

This commit is contained in:
SPRINX0\prochazka
2024-08-28 13:03:03 +02:00
parent 61c3ff423a
commit e71d278b20
2 changed files with 23 additions and 10 deletions

View File

@@ -107,6 +107,15 @@ const driver = {
case 'dropCollection':
await this.script(pool, `db.dropCollection('${operation.collection}')`);
break;
case 'renameCollection':
await this.script(pool, `db.renameCollection('${operation.collection}', '${operation.newName}')`);
break;
case 'cloneCollection':
await this.script(
pool,
`db.collection('${operation.collection}').aggregate([{$out: '${operation.newName}'}]).toArray()`
);
break;
default:
throw new Error(`Operation type ${type} not supported`);
}