Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,11 @@ config.enableSwaggerHttps = false
*/
config.swaggerHost = undefined

/**
* If set to true, models will be loaded as esm modules (export default)
* - options: 'true', 'false' (default: 'false')
* @type {boolean}
*/
config.esm = false

module.exports = config
10 changes: 10 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,3 +487,13 @@ config.enableSwaggerHttps = false
*/
config.swaggerHost = undefined
```

## esm
```javascript
/**
* If set to true, models will be loaded as esm modules (export default)
* - options: 'true', 'false' (default: 'false')
* @type {boolean}
*/
config.esm = false
```
3 changes: 2 additions & 1 deletion utilities/model-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ module.exports = function(mongoose, logger, config) {
const ext = path.extname(file)
if (ext === '.js') {
const modelName = path.basename(file, '.js')
const schema = require(modelPath + '/' + modelName)(mongoose)
const schemaPrecursor = require(modelPath + '/' + modelName)
const schema = (config.esm ? schemaPrecursor.default : schemaPrecursor)(mongoose)

// EXPL: Add text index if enabled
if (config.enableTextSearch) {
Expand Down
10 changes: 10 additions & 0 deletions website/versioned_docs/version-2.0.x/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,3 +486,13 @@ config.enableSwaggerHttps = false
*/
config.swaggerHost = undefined
```

## esm
```javascript
/**
* If set to true, models will be loaded as esm modules (export default)
* - options: 'true', 'false' (default: 'false')
* @type {boolean}
*/
config.esm = false
```