wingbot-mongodb 2.22.0-alpha.3 → 2.22.0-alpha.4
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.
- package/package.json +1 -1
- package/src/BaseStorage.js +18 -1
package/package.json
CHANGED
package/src/BaseStorage.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
const mongodb = require('mongodb'); // eslint-disable-line no-unused-vars
|
|
7
6
|
const crypto = require('crypto');
|
|
8
7
|
const defaultLogger = require('./defaultLogger');
|
|
9
8
|
|
|
@@ -90,6 +89,24 @@ class BaseStorage {
|
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
91
|
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* @protected
|
|
95
|
+
* @param {string} attr
|
|
96
|
+
* @param {{[key: string]: any}} obj
|
|
97
|
+
* @returns {{[key: string]: any}}
|
|
98
|
+
*/
|
|
99
|
+
_expandObjectToSet (attr, obj) {
|
|
100
|
+
const keys = Object.keys(obj);
|
|
101
|
+
if (keys.length === 0) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return keys
|
|
105
|
+
.reduce((o, key) => Object.assign(o, {
|
|
106
|
+
[`${attr}.${key}`]: obj[key]
|
|
107
|
+
}), {});
|
|
108
|
+
}
|
|
109
|
+
|
|
93
110
|
async _getOrCreateCollection (name) {
|
|
94
111
|
const db = typeof this._mongoDb === 'function'
|
|
95
112
|
? await this._mongoDb()
|