Pierre Noël c0d9dd26d1 Fix findOne with PK as one of the params
Signed-off-by: Pierre Noël <pierre.noel@strapi.io>
2020-03-06 09:08:20 +01:00

15 lines
316 B
JavaScript

'use strict';
const _ = require('lodash');
module.exports = {
replaceIdByPrimaryKey: (params, model) => {
const newParams = { ...params };
if (_.has(params, 'id')) {
delete newParams.id;
newParams[model.primaryKey] = params[model.primaryKey] || params.id;
}
return newParams;
},
};