Update findOne

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
Alexandre Bodin 2020-07-02 16:26:09 +02:00
parent 5f01d9ebe1
commit 44a7e2321d
3 changed files with 7 additions and 13 deletions

View File

@ -35,7 +35,7 @@ module.exports = (ability, action, model) => ({
queryFrom(query) {
return {
...query,
_where: _.concat(this.query, query._where),
_where: _.concat(this.query, query._where || {}),
};
},

View File

@ -101,21 +101,15 @@ module.exports = {
state: { userAbility },
params: { model, id },
} = ctx;
const contentManagerService = strapi.plugins['content-manager'].services.contentmanager;
const pm = strapi.admin.services.permission.createPermissionsManager(
const { pm, entity } = await findEntityAndCheckPermissions(
userAbility,
ACTIONS.read,
model
model,
id
);
const entry = await contentManagerService.fetch(model, id, { query: pm.query });
// Entry not found
if (!entry) {
return ctx.notFound('Entry not found');
}
ctx.body = pm.sanitize(entry);
ctx.body = pm.sanitize(entity);
},
/**

View File

@ -97,7 +97,7 @@ const hasDeepFilters = (whereClauses = []) => {
return value.filter(hasDeepFilters).length > 0;
}
return field.split('.').length > 1;
return field.split('.').length > 2;
}).length > 0
);
};