@toa.io/storages.mongodb 1.0.0-alpha.55 → 1.0.0-alpha.58

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/storages.mongodb",
3
- "version": "1.0.0-alpha.55",
3
+ "version": "1.0.0-alpha.58",
4
4
  "description": "Toa MongoDB Storage Connector",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -19,13 +19,13 @@
19
19
  "test": "echo \"Error: run tests from root\" && exit 1"
20
20
  },
21
21
  "dependencies": {
22
- "@toa.io/console": "1.0.0-alpha.55",
23
- "@toa.io/conveyor": "1.0.0-alpha.55",
24
- "@toa.io/core": "1.0.0-alpha.55",
25
- "@toa.io/generic": "1.0.0-alpha.55",
26
- "@toa.io/pointer": "1.0.0-alpha.55",
22
+ "@toa.io/console": "1.0.0-alpha.56",
23
+ "@toa.io/conveyor": "1.0.0-alpha.56",
24
+ "@toa.io/core": "1.0.0-alpha.58",
25
+ "@toa.io/generic": "1.0.0-alpha.56",
26
+ "@toa.io/pointer": "1.0.0-alpha.58",
27
27
  "mongodb": "6.7.0",
28
28
  "saslprep": "1.0.3"
29
29
  },
30
- "gitHead": "39465f6af0009b07fd800c5b97244fadd6d3afe6"
30
+ "gitHead": "f8ec99fc117db7ac763375249b11f74f84a5db48"
31
31
  }
package/src/client.js CHANGED
@@ -17,6 +17,8 @@ const { MongoClient } = require('mongodb')
17
17
  const INSTANCES = {}
18
18
 
19
19
  class Client extends Connector {
20
+ name
21
+
20
22
  /**
21
23
  * @public
22
24
  * @type {import('mongodb').Collection}
@@ -58,8 +60,8 @@ class Client extends Connector {
58
60
  async open () {
59
61
  const urls = await this.resolveURLs()
60
62
  const dbname = this.resolveDB()
61
- const collname = this.locator.lowercase
62
63
 
64
+ this.name = this.locator.lowercase
63
65
  this.key = getKey(dbname, urls)
64
66
 
65
67
  INSTANCES[this.key] ??= this.createInstance(urls)
@@ -70,13 +72,13 @@ class Client extends Connector {
70
72
  const db = this.instance.client.db(dbname)
71
73
 
72
74
  try {
73
- this.collection = await db.createCollection(collname)
75
+ this.collection = await db.createCollection(this.name)
74
76
  } catch (e) {
75
77
  if (e.code !== ALREADY_EXISTS) {
76
78
  throw e
77
79
  }
78
80
 
79
- this.collection = db.collection(collname)
81
+ this.collection = db.collection(this.name)
80
82
  }
81
83
  }
82
84
 
package/src/storage.js CHANGED
@@ -81,7 +81,7 @@ class Storage extends Connector {
81
81
  if (id)
82
82
  return false
83
83
  else
84
- throw new exceptions.DuplicateException()
84
+ throw new exceptions.DuplicateException(this.#client.name, entity)
85
85
  } else if (error.cause?.code === 'ECONNREFUSED') {
86
86
  // This is temporary and should be replaced with a class decorator.
87
87
  if (attempt > 10)