wingbot-mongodb 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/BaseStorage.js +19 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot-mongodb",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "MongoDB storage for wingbot.ai",
5
5
  "main": "src/main.js",
6
6
  "scripts": {
@@ -480,6 +480,25 @@ class BaseStorage {
480
480
 
481
481
  return h.digest('base64');
482
482
  }
483
+
484
+ /**
485
+ * Drop collection
486
+ *
487
+ * @returns {Promise}
488
+ */
489
+ async drop () {
490
+ const db = typeof this._mongoDb === 'function'
491
+ ? await this._mongoDb()
492
+ : this._mongoDb;
493
+
494
+ await db.dropCollection(this._collectionName)
495
+ .catch(() => {});
496
+
497
+ this._collection = null;
498
+ this._indexing = null;
499
+ this._shouldIndexBeforeRead = null;
500
+ this._shouldWaitForIndex = null;
501
+ }
483
502
  }
484
503
 
485
504
  module.exports = BaseStorage;