exposes errors, fixes bug with globals and localization
This commit is contained in:
5
errors.js
Normal file
5
errors.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const { APIError } = require('./src/errors');
|
||||
|
||||
module.exports = {
|
||||
APIError,
|
||||
};
|
||||
@@ -6,20 +6,26 @@ const localizationPlugin = require('../localization/plugin');
|
||||
|
||||
const buildModel = (config) => {
|
||||
if (config.globals && config.globals.length > 0) {
|
||||
const globalsSchema = new mongoose.Schema({}, { discriminatorKey: 'globalType', timestamps: true })
|
||||
.plugin(localizationPlugin, config.localization)
|
||||
.plugin(autopopulate)
|
||||
.plugin(mongooseHidden);
|
||||
const globalsSchema = new mongoose.Schema({}, { discriminatorKey: 'globalType', timestamps: true });
|
||||
|
||||
if (config.localization) {
|
||||
globalsSchema.plugin(localizationPlugin, config.localization);
|
||||
}
|
||||
|
||||
globalsSchema.plugin(autopopulate);
|
||||
globalsSchema.plugin(mongooseHidden);
|
||||
|
||||
const Globals = mongoose.model('globals', globalsSchema);
|
||||
|
||||
Object.values(config.globals).forEach((globalConfig) => {
|
||||
const globalSchema = buildSchema(globalConfig.fields);
|
||||
|
||||
globalSchema
|
||||
.plugin(localizationPlugin, config.localization)
|
||||
.plugin(autopopulate)
|
||||
.plugin(mongooseHidden);
|
||||
if (config.localization) {
|
||||
globalSchema.plugin(localizationPlugin, config.localization);
|
||||
}
|
||||
|
||||
globalSchema.plugin(autopopulate);
|
||||
globalSchema.plugin(mongooseHidden);
|
||||
|
||||
Globals.discriminator(globalConfig.slug, globalSchema);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user