mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 23:57:32 +00:00
Lint strapi-mongoose
This commit is contained in:
parent
e593d03ae5
commit
6fe297e252
@ -10,16 +10,21 @@ const mongoose = require('mongoose');
|
||||
const Mongoose = mongoose.Mongoose;
|
||||
const mongooseUtils = require('mongoose/lib/utils');
|
||||
|
||||
// Strapi helpers for models.
|
||||
const { models: utilsModels } = require('strapi-utils');
|
||||
|
||||
|
||||
// Local helpers.
|
||||
const utils = require('./utils/');
|
||||
|
||||
// Strapi helpers for models.
|
||||
const { models: utilsModels, logger } = require('strapi-utils');
|
||||
|
||||
/**
|
||||
* Mongoose hook
|
||||
*/
|
||||
|
||||
/* eslint-disable prefer-template */
|
||||
/* eslint-disable no-case-declarations */
|
||||
/* eslint-disable no-const-assign */
|
||||
/* eslint-disable no-unused-vars */
|
||||
module.exports = function (strapi) {
|
||||
const hook = {
|
||||
|
||||
@ -47,7 +52,7 @@ module.exports = function (strapi) {
|
||||
const { authenticationDatabase, ssl } = _.defaults(connection.options, strapi.config.hook.settings.mongoose);
|
||||
|
||||
// Connect to mongo database
|
||||
const connectOptions = {}
|
||||
const connectOptions = {};
|
||||
|
||||
if (!_.isEmpty(username)) {
|
||||
connectOptions.user = username;
|
||||
@ -121,12 +126,12 @@ module.exports = function (strapi) {
|
||||
this._mongooseOptions.populate[association.alias].match = {
|
||||
[`${association.via}.${association.filter}`]: association.alias,
|
||||
[`${association.via}.kind`]: definition.globalId
|
||||
}
|
||||
};
|
||||
|
||||
// Select last related to an entity.
|
||||
this._mongooseOptions.populate[association.alias].options = {
|
||||
sort: '-createdAt'
|
||||
}
|
||||
};
|
||||
} else {
|
||||
this._mongooseOptions.populate[association.alias].path = `${association.alias}.ref`;
|
||||
}
|
||||
@ -160,7 +165,7 @@ module.exports = function (strapi) {
|
||||
_.forEach(postLifecycle, (fn, key) => {
|
||||
if (_.isFunction(target[model.toLowerCase()][fn])) {
|
||||
collection.schema.post(key, function (doc, next) {
|
||||
target[model.toLowerCase()][fn](this, doc).then(next).catch(err => strapi.log.error(err))
|
||||
target[model.toLowerCase()][fn](this, doc).then(next).catch(err => strapi.log.error(err));
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -444,7 +449,7 @@ module.exports = function (strapi) {
|
||||
});
|
||||
},
|
||||
|
||||
getQueryParams: (value, type, key) => {
|
||||
getQueryParams: (value, type, key) => {
|
||||
const result = {};
|
||||
|
||||
switch (type) {
|
||||
@ -649,7 +654,7 @@ module.exports = function (strapi) {
|
||||
ref: obj.refId,
|
||||
kind: globalId,
|
||||
[association.filter]: obj.field
|
||||
}
|
||||
};
|
||||
});
|
||||
break;
|
||||
case 'oneToManyMorph':
|
||||
@ -662,7 +667,7 @@ module.exports = function (strapi) {
|
||||
}
|
||||
|
||||
return value;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if (association.type === 'model') {
|
||||
|
||||
@ -29,8 +29,8 @@ const watcher = (label, pckgName, type = 'front') => {
|
||||
const packagesPath = path.resolve(process.env.PWD, 'packages');
|
||||
shell.ls('* -d', packagesPath)
|
||||
// TODO temporary just for eslint
|
||||
.filter(package => package === 'strapi-knex')
|
||||
// .filter(package => package !== 'README.md')
|
||||
.filter(package => package === 'strapi-mongoose')
|
||||
// .filter(package => package !== 'README.md' || package === 'strapi-middleware-views' || package === 'strapi-lint' || package === 'strapi-plugin-settings-manager')
|
||||
.forEach(package => {
|
||||
watcher(`Testing ${package}`, package);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user