monastery 1.38.3 → 1.39.0

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,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
+ ## [1.39.0](https://github.com/boycce/monastery/compare/1.38.3...1.39.0) (2022-09-11)
6
+
5
7
  ### [1.38.3](https://github.com/boycce/monastery/compare/1.38.2...1.38.3) (2022-08-17)
6
8
 
7
9
  ### [1.38.2](https://github.com/boycce/monastery/compare/1.38.1...1.38.2) (2022-07-31)
@@ -13,7 +13,7 @@ Setup model definitions from a folder location
13
13
 
14
14
  ### Returns
15
15
 
16
- An array of [model](../model) instances, the model instances will also be avaliable at:
16
+ A promise with an array of [model](../model) instances, the model instances will also be avaliable at:
17
17
  ```js
18
18
  db.{model-name}
19
19
  db.model.{model-name}
@@ -35,6 +35,6 @@ export default {
35
35
  ```
36
36
 
37
37
  ```js
38
- db.models(__dirname + "models")
38
+ await db.models(__dirname + "models")
39
39
  db.user.insert()
40
40
  ```
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ let fs = require('fs')
1
2
  let debug = require('debug')
2
3
  let monk = require('monk')
3
4
  let util = require('./util')
@@ -74,19 +75,20 @@ let arrayWithSchema = function(array, schema) {
74
75
  return array
75
76
  }
76
77
 
77
- let models = function(path) {
78
+ let models = async function(path) {
78
79
  /**
79
80
  * Setup model definitions from a folder location
80
81
  * @param {string} pathname
81
- * @return {object} - e.g. { user: , article: , .. }
82
+ * @return {Promise(object)} - e.g. { user: , article: , .. }
82
83
  * @this Manager
83
84
  */
84
85
  let models = {}
85
86
  if (!path || typeof path !== 'string') {
86
87
  throw 'The path must be a valid pathname'
87
88
  }
88
- require('fs').readdirSync(path).forEach(filename => {
89
- let definition = require(require('path').join(path, filename)).default
89
+ await fs.readdirSync(path).forEach(async filename => {
90
+ let definition = await import(require('path').join(path, filename))
91
+ // let definition = require(require('path').join(path, filename)).default
90
92
  let name = filename.replace('.js', '')
91
93
  models[name] = this.model(name, definition)
92
94
  })
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "monastery",
3
3
  "description": "⛪ A straight forward MongoDB ODM built around Monk",
4
4
  "author": "Ricky Boyce",
5
- "version": "1.38.3",
5
+ "version": "1.39.0",
6
6
  "license": "MIT",
7
7
  "repository": "github:boycce/monastery",
8
8
  "homepage": "https://boycce.github.io/monastery/",