Last active
May 9, 2020 20:53
-
-
Save luizamboni/a43df8c8ea950925f86fea7a517d5a73 to your computer and use it in GitHub Desktop.
pageContent service for strapi tutorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const modelName = 'page-content' | |
module.exports = { | |
_validate(data) { | |
if (!(data.startAt < data.endAt)){ | |
throw new Error("startAt should be less than endAt date") | |
} | |
}, | |
create(data, { files } = {}) { | |
this._validate(data); | |
return strapi.entityService | |
.create({ data, files }, { model: modelName }) | |
}, | |
update(params, data, { files } = {}) { | |
this._validate(data); | |
return strapi.entityService | |
.update({ params, data, files }, { model: modelName }) | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment