summaryrefslogtreecommitdiffstats
path: root/node_modules/mongodb/lib/operations/drop.js
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/mongodb/lib/operations/drop.js
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/mongodb/lib/operations/drop.js')
-rw-r--r--node_modules/mongodb/lib/operations/drop.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/node_modules/mongodb/lib/operations/drop.js b/node_modules/mongodb/lib/operations/drop.js
new file mode 100644
index 0000000..be03716
--- /dev/null
+++ b/node_modules/mongodb/lib/operations/drop.js
@@ -0,0 +1,53 @@
+'use strict';
+
+const Aspect = require('./operation').Aspect;
+const CommandOperation = require('./command');
+const defineAspects = require('./operation').defineAspects;
+const handleCallback = require('../utils').handleCallback;
+
+class DropOperation extends CommandOperation {
+ constructor(db, options) {
+ const finalOptions = Object.assign({}, options, db.s.options);
+
+ if (options.session) {
+ finalOptions.session = options.session;
+ }
+
+ super(db, finalOptions);
+ }
+
+ execute(callback) {
+ super.execute((err, result) => {
+ if (err) return handleCallback(callback, err);
+ if (result.ok) return handleCallback(callback, null, true);
+ handleCallback(callback, null, false);
+ });
+ }
+}
+
+defineAspects(DropOperation, Aspect.WRITE_OPERATION);
+
+class DropCollectionOperation extends DropOperation {
+ constructor(db, name, options) {
+ super(db, options);
+
+ this.name = name;
+ this.namespace = `${db.namespace}.${name}`;
+ }
+
+ _buildCommand() {
+ return { drop: this.name };
+ }
+}
+
+class DropDatabaseOperation extends DropOperation {
+ _buildCommand() {
+ return { dropDatabase: 1 };
+ }
+}
+
+module.exports = {
+ DropOperation,
+ DropCollectionOperation,
+ DropDatabaseOperation
+};