fix(contentful-plugin): Keep existing entry fields

This commit is contained in:
Oliver Windall Juhl
2020-08-27 18:03:46 +02:00
committed by GitHub
parent 9dc6999a9a
commit eb47896668
5 changed files with 76 additions and 26 deletions
@@ -0,0 +1,17 @@
import _ from "lodash"
function compareObjectsByProp(object1, object2, prop) {
if (Array.isArray(object1[prop])) {
object2[prop] = object2[prop].map(({ _id, ...rest }) => rest)
return (
_.differenceWith(object1[prop], object2[prop], _.isEqual).length === 0
)
} else if (typeof object1[prop] === "object") {
delete object2[prop]._id
return _.isEqual(object1[prop], object2[prop])
} else {
return object1[prop] === object2[prop]
}
}
export default compareObjectsByProp