wingbot-mongodb 2.22.0-alpha.4 → 2.22.0-alpha.5
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/.nyc_output/1f0c249b-861d-4ebb-a415-267bb18646dd.json +1 -0
- package/.nyc_output/processinfo/{75b2d1cb-d4fe-472b-a674-acdcb631b536.json → 1f0c249b-861d-4ebb-a415-267bb18646dd.json} +1 -1
- package/.nyc_output/processinfo/index.json +1 -1
- package/package.json +1 -1
- package/src/BaseStorage.js +17 -0
- package/src/NotificationsStorage.js +8 -8
- package/.nyc_output/75b2d1cb-d4fe-472b-a674-acdcb631b536.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"parent":null,"pid":
|
|
1
|
+
{"parent":null,"pid":83585,"argv":["/usr/local/bin/node","/Users/david/Development/wingbot-mongodb/node_modules/.bin/mocha","./test"],"execArgv":[],"cwd":"/Users/david/Development/wingbot-mongodb","time":1650546848107,"ppid":83584,"coverageFilename":"/Users/david/Development/wingbot-mongodb/.nyc_output/1f0c249b-861d-4ebb-a415-267bb18646dd.json","externalId":"","uuid":"1f0c249b-861d-4ebb-a415-267bb18646dd","files":["/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js","/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js","/Users/david/Development/wingbot-mongodb/src/BaseStorage.js","/Users/david/Development/wingbot-mongodb/src/defaultLogger.js","/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js","/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js","/Users/david/Development/wingbot-mongodb/src/tokenFactory.js","/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js","/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js","/Users/david/Development/wingbot-mongodb/src/StateStorage.js"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"processes":{"
|
|
1
|
+
{"processes":{"1f0c249b-861d-4ebb-a415-267bb18646dd":{"parent":null,"children":[]}},"files":{"/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/BaseStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/defaultLogger.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/tokenFactory.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"],"/Users/david/Development/wingbot-mongodb/src/StateStorage.js":["1f0c249b-861d-4ebb-a415-267bb18646dd"]},"externalIds":{}}
|
package/package.json
CHANGED
package/src/BaseStorage.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
+
const { ObjectId } = require('mongodb');
|
|
6
7
|
const crypto = require('crypto');
|
|
7
8
|
const defaultLogger = require('./defaultLogger');
|
|
8
9
|
|
|
@@ -89,6 +90,22 @@ class BaseStorage {
|
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
/**
|
|
94
|
+
* @example
|
|
95
|
+
* {
|
|
96
|
+
* _id: ObjectId.isValid(id) ? new ObjectId(input) : input
|
|
97
|
+
* }
|
|
98
|
+
*
|
|
99
|
+
* @protected
|
|
100
|
+
* @param {string} id
|
|
101
|
+
* @returns {string|ObjectId}
|
|
102
|
+
*/
|
|
103
|
+
_id (id) {
|
|
104
|
+
return ObjectId.isValid(id) && `${id}`.length === 24
|
|
105
|
+
? new ObjectId(id)
|
|
106
|
+
: id;
|
|
107
|
+
}
|
|
108
|
+
|
|
92
109
|
/**
|
|
93
110
|
*
|
|
94
111
|
* @protected
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
const mongodb = require('mongodb');
|
|
7
7
|
const defaultLogger = require('./defaultLogger');
|
|
8
8
|
|
|
9
|
-
const {
|
|
9
|
+
const { ObjectId } = mongodb;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @typedef Target {Object}
|
|
@@ -453,8 +453,8 @@ class NotificationsStorage {
|
|
|
453
453
|
const c = await this._getCollection(this.taksCollection);
|
|
454
454
|
|
|
455
455
|
const res = await c.findOne({
|
|
456
|
-
_id:
|
|
457
|
-
?
|
|
456
|
+
_id: ObjectId.isValid(taskId)
|
|
457
|
+
? ObjectId.createFromHexString(taskId)
|
|
458
458
|
: taskId
|
|
459
459
|
});
|
|
460
460
|
|
|
@@ -470,8 +470,8 @@ class NotificationsStorage {
|
|
|
470
470
|
const c = await this._getCollection(this.taksCollection);
|
|
471
471
|
|
|
472
472
|
const res = await c.findOneAndUpdate({
|
|
473
|
-
_id:
|
|
474
|
-
?
|
|
473
|
+
_id: ObjectId.isValid(taskId)
|
|
474
|
+
? ObjectId.createFromHexString(taskId)
|
|
475
475
|
: taskId
|
|
476
476
|
}, {
|
|
477
477
|
$set: data
|
|
@@ -607,7 +607,7 @@ class NotificationsStorage {
|
|
|
607
607
|
});
|
|
608
608
|
ret = this._mapCampaign(res.value);
|
|
609
609
|
} else {
|
|
610
|
-
const id = new
|
|
610
|
+
const id = new ObjectId();
|
|
611
611
|
ret = { id: id.toHexString(), _id: id, ...campaign };
|
|
612
612
|
if (updateCampaign) {
|
|
613
613
|
Object.assign(ret, updateCampaign);
|
|
@@ -740,7 +740,7 @@ class NotificationsStorage {
|
|
|
740
740
|
useCondition = {
|
|
741
741
|
...useCondition,
|
|
742
742
|
_id: {
|
|
743
|
-
$lt:
|
|
743
|
+
$lt: ObjectId.createFromHexString(key._id)
|
|
744
744
|
}
|
|
745
745
|
};
|
|
746
746
|
}
|
|
@@ -899,7 +899,7 @@ class NotificationsStorage {
|
|
|
899
899
|
condition = {
|
|
900
900
|
...condition,
|
|
901
901
|
_id: {
|
|
902
|
-
$gt:
|
|
902
|
+
$gt: ObjectId.createFromHexString(key._id)
|
|
903
903
|
}
|
|
904
904
|
};
|
|
905
905
|
}
|