@toa.io/storages.mongodb 1.0.0-alpha.182 → 1.0.0-alpha.185

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 +2 -2
  2. package/src/storage.js +7 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/storages.mongodb",
3
- "version": "1.0.0-alpha.182",
3
+ "version": "1.0.0-alpha.185",
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",
@@ -27,5 +27,5 @@
27
27
  "openspan": "1.0.0-alpha.173",
28
28
  "saslprep": "1.0.3"
29
29
  },
30
- "gitHead": "99d0b79680455e8746274bcfa07a5674e8514bff"
30
+ "gitHead": "77151bc325f47d41cd719713c14e4a42eecfaa45"
31
31
  }
package/src/storage.js CHANGED
@@ -13,8 +13,6 @@ class Storage extends Connector {
13
13
  #collection
14
14
  #entity
15
15
 
16
- #logs
17
-
18
16
  constructor (client, entity) {
19
17
  super()
20
18
 
@@ -22,8 +20,6 @@ class Storage extends Connector {
22
20
  this.#entity = entity
23
21
 
24
22
  this.depends(client)
25
-
26
- this.#logs = console.fork({ collection: client.name })
27
23
  }
28
24
 
29
25
  get raw () {
@@ -165,7 +161,7 @@ class Storage extends Connector {
165
161
  options.upsert = true
166
162
  options.returnDocument = ReturnDocument.AFTER
167
163
 
168
- this.#logs.debug('Database query', { method: 'findOneAndUpdate', criteria, update, options })
164
+ console.debug('Database query', { collection: this.#collection.name, method: 'findOneAndUpdate', criteria, update, options })
169
165
 
170
166
  const result = await this.#collection.findOneAndUpdate(criteria, update, options)
171
167
 
@@ -199,7 +195,7 @@ class Storage extends Connector {
199
195
  console.info('Creating index', { fields, options })
200
196
 
201
197
  await this.#collection.createIndex(fields, options)
202
- .catch((e) => this.#logs.warn('Index creation failed', { name, fields, error: e }))
198
+ .catch((e) => console.warn('MongoDB index creation failed', { collection: this.#collection.name, name, fields, error: e }))
203
199
 
204
200
  indexes.push(name)
205
201
  }
@@ -224,7 +220,8 @@ class Storage extends Connector {
224
220
  console.info('Creating unique index', { name, fields, options })
225
221
 
226
222
  await this.#collection.createIndex(fields, options)
227
- .catch((e) => this.#logs.warn('Unique index creation failed', { name, fields, error: e }))
223
+ .catch((e) => console.warn('MongoDB unique index creation failed',
224
+ { collection: this.#collection.name, name, fields, error: e }))
228
225
 
229
226
  return name
230
227
  }
@@ -234,7 +231,7 @@ class Storage extends Connector {
234
231
  const obsolete = current.filter((name) => !desired.includes(name))
235
232
 
236
233
  if (obsolete.length > 0) {
237
- this.#logs.info('Removing obsolete indexes', { indexes: obsolete.join(', ') })
234
+ console.info('Removing obsolete indexes', { collection: this.#collection.name, indexes: obsolete.join(', ') })
238
235
 
239
236
  await Promise.all(obsolete.map((name) => this.#collection.dropIndex(name)))
240
237
  }
@@ -265,7 +262,8 @@ class Storage extends Connector {
265
262
  }
266
263
 
267
264
  debug (method, attributes) {
268
- this.#logs.debug('Database query', {
265
+ console.debug('Database query', {
266
+ collection: this.#collection.name,
269
267
  method,
270
268
  ...attributes
271
269
  })