mirror of
https://github.com/strapi/strapi.git
synced 2025-12-12 07:27:46 +00:00
Move orm condition directly into the pruneObsoleteRelations query
Signed-off-by: Convly <jean-sebastien.herbaux@epitech.eu>
This commit is contained in:
parent
8a2050add0
commit
a615f16bb5
@ -59,14 +59,18 @@ const pruneObsoleteRelations = async () => {
|
||||
const { upload: plugin } = strapi.plugins;
|
||||
const modelIsNotDefined = !plugin || !plugin.models || !plugin.models.file;
|
||||
|
||||
if (modelIsNotDefined || plugin.models.file.orm !== 'mongoose') {
|
||||
return;
|
||||
if (modelIsNotDefined) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
await strapi.query('file', 'upload').custom(pruneObsoleteRelationsQuery)();
|
||||
};
|
||||
|
||||
const pruneObsoleteRelationsQuery = ({ model }) => {
|
||||
if (model.orm !== 'mongoose') {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const models = Array.from(strapi.db.models.values());
|
||||
const modelsId = models.map(model => model.globalId);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user