Skip to content

Commit

Permalink
patch/3.6.5 restore integration version of removeAdditionalProperties…
Browse files Browse the repository at this point in the history
…WithRelations

It was added in commit d554388 of animals and not on branch
  • Loading branch information
kathyavini committed Jul 19, 2024
1 parent 16599b5 commit 5b2f447
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/api/src/controllers/baseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ function removeAdditionalProperties(model, data) {
return lodash.pick(data, Object.keys(model.jsonSchema.properties));
}

function removeAdditionalPropertiesWithRelations(model, data) {
const modelKeys = Object.keys(model.jsonSchema.properties);
const relationKeys = Object.keys(model.relationMappings || {});

if (Array.isArray(data)) {
const arrayWithoutAdditionalProperties = data.map((obj) => {
return lodash.pick(obj, [...modelKeys, ...relationKeys]);
});
return arrayWithoutAdditionalProperties;
}
//remove all the unnecessary properties

return lodash.pick(data, [...modelKeys, ...relationKeys]);
}

export default {
async get(model) {
if (model.isSoftDelete) {
Expand Down

0 comments on commit 5b2f447

Please sign in to comment.