mirror of
https://github.com/strapi/strapi.git
synced 2025-09-20 05:52:08 +00:00
Fix undefined model case
This commit is contained in:
parent
8e1e7317a7
commit
b13c272f11
@ -53,6 +53,8 @@ const getTimestamps = (model: Model) => {
|
||||
};
|
||||
|
||||
const getNonWritableAttributes = (model: Model) => {
|
||||
if (!model) return [];
|
||||
|
||||
const nonWritableAttributes = _.reduce(
|
||||
model.attributes,
|
||||
(acc, attr, attrName) => (attr.writable === false ? acc.concat(attrName) : acc),
|
||||
@ -63,6 +65,8 @@ const getNonWritableAttributes = (model: Model) => {
|
||||
};
|
||||
|
||||
const getWritableAttributes = (model: Model) => {
|
||||
if (!model) return [];
|
||||
|
||||
return _.difference(Object.keys(model.attributes), getNonWritableAttributes(model));
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user