wingbot-mongodb 2.21.0 → 2.22.0-alpha.1

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 CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "wingbot-mongodb",
3
- "version": "2.21.0",
3
+ "version": "2.22.0-alpha.1",
4
4
  "description": "MongoDB storage for wingbot.ai",
5
5
  "main": "src/main.js",
6
6
  "scripts": {
7
7
  "test": "npm run test:lint && npm run test:coverage && npm run test:coverage:threshold",
8
- "test:unit": "mocha ./test/**/*.test.js",
8
+ "test:unit": "mocha ./test/**/*.js",
9
9
  "test:unit:watch": "npm run test:unit -- --watch",
10
10
  "test:cosmos": "cross-env DB_TYPE=cosmos mocha ./test",
11
11
  "test:coverage": "nyc --reporter=html mocha ./test && nyc report",
@@ -45,12 +45,12 @@
45
45
  "jsdoc-to-markdown": "^7.1.1",
46
46
  "jsdoc-tsimport-plugin": "^1.0.5",
47
47
  "mocha": "^9.2.2",
48
- "mongodb": "^3.7.3",
48
+ "mongodb": "^4.5.0",
49
49
  "nyc": "^15.1.0",
50
- "wingbot": "^3.30.0"
50
+ "wingbot": "^3.30.2"
51
51
  },
52
52
  "peerDependencies": {
53
- "mongodb": "^3.0.0"
53
+ "mongodb": "^4.0.0"
54
54
  },
55
55
  "optionalDependencies": {
56
56
  "wingbot": "^3.0.0"
@@ -774,10 +774,11 @@ class NotificationsStorage {
774
774
  * @param {string|string[]} senderId
775
775
  * @param {string} pageId
776
776
  * @param {string} tag
777
- * @param {boolean} [upsert]
777
+ * @param {boolean} [onlyToKnown]
778
778
  * @returns {Promise}
779
779
  */
780
- async subscribe (senderId, pageId, tag, upsert = true) {
780
+ async subscribe (senderId, pageId, tag, onlyToKnown) {
781
+ // !IMPORTANT: do not add a default value to the fourth parameter!
781
782
  const senderIds = Array.isArray(senderId) ? senderId : [senderId];
782
783
 
783
784
  if (senderIds.length === 0) {
@@ -790,9 +791,15 @@ class NotificationsStorage {
790
791
  updateOne: {
791
792
  filter: { senderId: sid, pageId },
792
793
  update: { $addToSet: { subs: tag } },
793
- upsert
794
+ upsert: !onlyToKnown
794
795
  }
795
- }))
796
+ })),
797
+ {
798
+ ordered: false,
799
+ writeConcern: {
800
+ w: onlyToKnown ? 0 : 1
801
+ }
802
+ }
796
803
  );
797
804
  }
798
805