Skip to content

Instantly share code, notes, and snippets.

@luizamboni
Last active May 9, 2020 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luizamboni/a43df8c8ea950925f86fea7a517d5a73 to your computer and use it in GitHub Desktop.
Save luizamboni/a43df8c8ea950925f86fea7a517d5a73 to your computer and use it in GitHub Desktop.
pageContent service for strapi tutorial
'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