monastery 3.0.7 → 3.0.9

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 CHANGED
@@ -2,6 +2,10 @@
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.9](https://github.com/boycce/monastery/compare/3.0.8...3.0.9) (2024-04-30)
6
+
7
+ ### [3.0.8](https://github.com/boycce/monastery/compare/3.0.7...3.0.8) (2024-04-30)
8
+
5
9
  ### [3.0.7](https://github.com/boycce/monastery/compare/3.0.5...3.0.7) (2024-04-29)
6
10
 
7
11
  ### [3.0.6](https://github.com/boycce/monastery/compare/3.0.5...3.0.6) (2024-04-29)
package/docs/readme.md CHANGED
@@ -94,6 +94,11 @@ You can view MongoDB's [compatibility table here](https://www.mongodb.com/docs/d
94
94
  - db.catch/then() moved to db.onError/db.onOpen()
95
95
  - next() is now redundant when returning promises from hooks, e.g. `afterFind: [async (data) => {...}]`
96
96
 
97
+ ## v2 Breaking Changes
98
+
99
+ - changed model.messages, array paths now must include '.$'
100
+ - updated AWS to client v3 (requires ES6 features, NodeJs >=14)
101
+
97
102
  ## Roadmap
98
103
 
99
104
  - Add Aggregate
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?.message == 'ns not found') return 'ns not found'
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?.[0] || null
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?.returnDocument === 'undefined') {
205
+ if (typeof (args.opts||{}).returnDocument === 'undefined') {
206
206
  args.opts.returnDocument = 'after'
207
207
  }
208
- if (typeof args.opts?.returnOriginal !== 'undefined') {
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?.message.match(/ns does not exist/)) return {}
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?.message.match(/ns does not exist/)) return []
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?.result || 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?.cache === false) {
163
- delete options?.cache
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]
@@ -174,14 +174,17 @@ Manager.prototype.isId = function(value) {
174
174
  return util.isId(value)
175
175
  }
176
176
 
177
- Manager.prototype.models = async function(pathname, waitForIndexes) {
177
+ Manager.prototype.models = async function(pathname, opts) {
178
178
  /**
179
179
  * Setup model definitions from a folder location
180
180
  * @param {string} pathname
181
+ * @param {object} opts:
182
+ * @param {boolean} opts.waitForIndexes - Wait for indexes to be created?
181
183
  * @return {Promise(object)} - e.g. { user: , article: , .. }
182
184
  * @this Manager
183
185
  */
184
186
  let out = {}
187
+ let { waitForIndexes } = opts || {}
185
188
  if (!pathname || typeof pathname !== 'string') {
186
189
  throw 'The path must be a valid pathname'
187
190
  }
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?._state?.match(/^open/)) {
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.7",
5
+ "version": "3.0.9",
6
6
  "license": "MIT",
7
7
  "repository": "github:boycce/monastery",
8
8
  "homepage": "https://boycce.github.io/monastery/",