monastery 2.2.4 → 2.2.5
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/index.js +11 -4
- 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
|
+
### [2.2.5](https://github.com/boycce/monastery/compare/2.2.4...2.2.5) (2024-04-30)
|
|
6
|
+
|
|
5
7
|
### [2.2.4](https://github.com/boycce/monastery/compare/2.2.3...2.2.4) (2024-04-30)
|
|
6
8
|
|
|
7
9
|
### [2.2.3](https://github.com/boycce/monastery/compare/2.2.2...2.2.3) (2024-04-28)
|
package/lib/index.js
CHANGED
|
@@ -80,16 +80,23 @@ let arrayWithSchema = function(array, schema) {
|
|
|
80
80
|
return array
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
let models = async function(pathname,
|
|
83
|
+
let models = async function(pathname, opts) {
|
|
84
84
|
/**
|
|
85
85
|
* Setup model definitions from a folder location
|
|
86
86
|
* @param {string} pathname
|
|
87
|
-
* @param {
|
|
88
|
-
*
|
|
87
|
+
* @param {object} opts:
|
|
88
|
+
* @param {boolean} opts.waitForIndexes - Wait for indexes to be created?
|
|
89
|
+
* @param {boolean} opts.commonJs - Use commonJs require() instead of ES6 import()
|
|
89
90
|
* @return {Promise(object)} - e.g. { user: , article: , .. }
|
|
90
91
|
* @this Manager
|
|
91
92
|
*/
|
|
92
93
|
let out = {}
|
|
94
|
+
opts = true
|
|
95
|
+
if (opts === true) {
|
|
96
|
+
opts = { waitForIndexes: true } // legacy support
|
|
97
|
+
console.warn('Depreciating: please use `{ waitForIndexes: true }` instead of `true` in db.models(pathname, `true`)')
|
|
98
|
+
}
|
|
99
|
+
let { waitForIndexes, commonJs } = opts || {}
|
|
93
100
|
if (!pathname || typeof pathname !== 'string') {
|
|
94
101
|
throw 'The path must be a valid pathname'
|
|
95
102
|
}
|
|
@@ -101,7 +108,7 @@ let models = async function(pathname, waitForIndexes, commonJs) {
|
|
|
101
108
|
let filepath = path.join(pathname, filename)
|
|
102
109
|
let definition
|
|
103
110
|
if (commonJs) {
|
|
104
|
-
definition = require(
|
|
111
|
+
definition = require(filepath).default
|
|
105
112
|
} else {
|
|
106
113
|
// We can't use require() here since we need to be able to import both CJS and ES6 modules
|
|
107
114
|
definition = ((await import(filepath))||{}).default
|
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": "2.2.
|
|
5
|
+
"version": "2.2.5",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "github:boycce/monastery",
|
|
8
8
|
"homepage": "https://boycce.github.io/monastery/",
|