create collection - generic operation

This commit is contained in:
Jan Prochazka
2024-08-16 12:40:44 +02:00
parent ecde2da2af
commit a89cb607b4
12 changed files with 174 additions and 18 deletions

View File

@@ -100,6 +100,16 @@ const driver = {
const res = func(db, ObjectId.createFromHexString);
if (isPromise(res)) await res;
},
async operation(pool, operation, options) {
const { type } = operation;
switch (type) {
case 'createCollection':
await this.script(pool, `db.createCollection('${operation.collection}')`);
default:
throw new Error(`Operation type ${type} not supported`);
}
// saveScriptToDatabase({ conid: connection._id, database: name }, `db.createCollection('${newCollection}')`);
},
async stream(pool, sql, options) {
let func;
try {