@toa.io/storages.mongodb 1.0.0-alpha.69 → 1.0.0-alpha.72
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 +2 -2
- package/src/storage.js +13 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/storages.mongodb",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.72",
|
|
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.67",
|
|
28
28
|
"saslprep": "1.0.3"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "919b587dfcdfab40d18f0f8bd24b34d8107f811a"
|
|
31
31
|
}
|
package/src/storage.js
CHANGED
|
@@ -31,7 +31,7 @@ class Storage extends Connector {
|
|
|
31
31
|
async get (query) {
|
|
32
32
|
const { criteria, options } = translate(query)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
this.debug('findOne', { criteria, options })
|
|
35
35
|
|
|
36
36
|
const record = await this.#collection.findOne(criteria, options)
|
|
37
37
|
|
|
@@ -41,7 +41,7 @@ class Storage extends Connector {
|
|
|
41
41
|
async find (query) {
|
|
42
42
|
const { criteria, options } = translate(query)
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
this.debug('find', { criteria, options })
|
|
45
45
|
|
|
46
46
|
const recordset = await this.#collection.find(criteria, options).toArray()
|
|
47
47
|
|
|
@@ -51,7 +51,7 @@ class Storage extends Connector {
|
|
|
51
51
|
async stream (query = undefined) {
|
|
52
52
|
const { criteria, options } = translate(query)
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
this.debug('find (stream)', { criteria, options })
|
|
55
55
|
|
|
56
56
|
return this.#collection.find(criteria, options).stream({ transform: from })
|
|
57
57
|
}
|
|
@@ -59,7 +59,7 @@ class Storage extends Connector {
|
|
|
59
59
|
async add (entity) {
|
|
60
60
|
const record = to(entity)
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
this.debug('insertOne', { record })
|
|
63
63
|
|
|
64
64
|
const result = await this.#collection.insertOne(record)
|
|
65
65
|
|
|
@@ -74,7 +74,7 @@ class Storage extends Connector {
|
|
|
74
74
|
|
|
75
75
|
const record = to(entity)
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
this.debug('findOneAndReplace', { criteria, record })
|
|
78
78
|
|
|
79
79
|
const result = await this.#collection.findOneAndReplace(criteria, record)
|
|
80
80
|
|
|
@@ -125,7 +125,7 @@ class Storage extends Connector {
|
|
|
125
125
|
|
|
126
126
|
options.returnDocument = ReturnDocument.AFTER
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
this.debug('findOneAndUpdate', { criteria, update, options })
|
|
129
129
|
|
|
130
130
|
const result = await this.#collection.findOneAndUpdate(criteria, update, options)
|
|
131
131
|
|
|
@@ -235,6 +235,13 @@ class Storage extends Connector {
|
|
|
235
235
|
return false
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
debug (method, attributes) {
|
|
239
|
+
console.debug('Database query', {
|
|
240
|
+
collection: this.#client.name,
|
|
241
|
+
method,
|
|
242
|
+
...attributes
|
|
243
|
+
})
|
|
244
|
+
}
|
|
238
245
|
}
|
|
239
246
|
|
|
240
247
|
const INDEX_TYPES = {
|