monastery 3.0.7 → 3.0.8
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/changelog.md +2 -0
- package/lib/collection.js +7 -7
- package/lib/index.js +2 -2
- package/lib/model.js +1 -1
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [3.0.8](https://github.com/boycce/monastery/compare/3.0.7...3.0.8) (2024-04-30)
|
|
6
|
+
|
|
5
7
|
### [3.0.7](https://github.com/boycce/monastery/compare/3.0.5...3.0.7) (2024-04-29)
|
|
6
8
|
|
|
7
9
|
### [3.0.6](https://github.com/boycce/monastery/compare/3.0.5...3.0.6) (2024-04-29)
|
package/lib/collection.js
CHANGED
|
@@ -114,7 +114,7 @@ Collection.prototype.drop = async function () {
|
|
|
114
114
|
await this.col.drop()
|
|
115
115
|
// this.col = null
|
|
116
116
|
} catch (err) {
|
|
117
|
-
if (err
|
|
117
|
+
if ((err||{}).message == 'ns not found') return 'ns not found'
|
|
118
118
|
throw err
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -186,7 +186,7 @@ Collection.prototype.find = async function (query, opts) {
|
|
|
186
186
|
Collection.prototype.findOne = async function (query, opts) {
|
|
187
187
|
const args = await this._middleware({ query, opts })
|
|
188
188
|
const docs = await this.col.find(args.query, args.opts).limit(1).toArray()
|
|
189
|
-
return docs
|
|
189
|
+
return (docs||{})[0] || null
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
Collection.prototype.findOneAndDelete = async function (query, opts) {
|
|
@@ -202,10 +202,10 @@ Collection.prototype.findOneAndUpdate = async function (query, update, opts) {
|
|
|
202
202
|
const args = await this._middleware({ query, update, opts })
|
|
203
203
|
let method = 'findOneAndUpdate'
|
|
204
204
|
|
|
205
|
-
if (typeof args.opts
|
|
205
|
+
if (typeof (args.opts||{}).returnDocument === 'undefined') {
|
|
206
206
|
args.opts.returnDocument = 'after'
|
|
207
207
|
}
|
|
208
|
-
if (typeof args.opts
|
|
208
|
+
if (typeof (args.opts||{}).returnOriginal !== 'undefined') {
|
|
209
209
|
this.manager.warn('The `returnOriginal` option is deprecated, use `returnDocument` instead.')
|
|
210
210
|
args.opts.returnDocument = args.opts.returnOriginal ? 'before' : 'after'
|
|
211
211
|
}
|
|
@@ -230,7 +230,7 @@ Collection.prototype.indexInformation = async function (opts) {
|
|
|
230
230
|
return await this.col.indexInformation(args.opts)
|
|
231
231
|
} catch (e) {
|
|
232
232
|
// col.indexInformation() throws an error if the collection is created yet...
|
|
233
|
-
if (e
|
|
233
|
+
if ((e||{}).message.match(/ns does not exist/)) return {}
|
|
234
234
|
else throw new Error(e)
|
|
235
235
|
}
|
|
236
236
|
}
|
|
@@ -241,7 +241,7 @@ Collection.prototype.indexes = async function (opts) {
|
|
|
241
241
|
return await this.col.indexes(args.opts)
|
|
242
242
|
} catch (e) {
|
|
243
243
|
// col.indexes() throws an error if the collection is created yet...
|
|
244
|
-
if (e
|
|
244
|
+
if ((e||{}).message.match(/ns does not exist/)) return []
|
|
245
245
|
else throw new Error(e)
|
|
246
246
|
}
|
|
247
247
|
}
|
|
@@ -317,7 +317,7 @@ Collection.prototype.update = async function (query, update, opts) {
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
const doc = await this.col[method](args.query, args.update, args.opts)
|
|
320
|
-
// return doc
|
|
320
|
+
// return (doc||{}).result || doc
|
|
321
321
|
return doc
|
|
322
322
|
}
|
|
323
323
|
|
package/lib/index.js
CHANGED
|
@@ -159,8 +159,8 @@ Manager.prototype.get = function(name, options) {
|
|
|
159
159
|
* @param {Object} [options] - options to pass to the collection
|
|
160
160
|
* @return {MongoDB Collection}
|
|
161
161
|
*/
|
|
162
|
-
if (!this.collections[name] || options
|
|
163
|
-
delete options
|
|
162
|
+
if (!this.collections[name] || (options||{}).cache === false) {
|
|
163
|
+
delete (options||{}).cache
|
|
164
164
|
this.collections[name] = new Collection(this, name, options)
|
|
165
165
|
}
|
|
166
166
|
return this.collections[name]
|
package/lib/model.js
CHANGED
|
@@ -263,7 +263,7 @@ Model.prototype._setupIndexes = async function(fields, opts={}) {
|
|
|
263
263
|
let textIndex = { name: 'text', key: {} }
|
|
264
264
|
|
|
265
265
|
// No db defined
|
|
266
|
-
if (!model.manager
|
|
266
|
+
if (!((model.manager||{})._state||{}).match(/^open/)) {
|
|
267
267
|
throw new Error(`Skipping createIndex on the '${model.name||''}' model, no mongodb connection found.`)
|
|
268
268
|
}
|
|
269
269
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "monastery",
|
|
3
3
|
"description": "⛪ A simple, straightforward MongoDB ODM",
|
|
4
4
|
"author": "Ricky Boyce",
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.8",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "github:boycce/monastery",
|
|
8
8
|
"homepage": "https://boycce.github.io/monastery/",
|