System Information
- Strapi Version: 3.2.4
- Operating System: macOS High Sierra 10.13.6
- Database: SQLite 5.0.0, PostgreSQL 8.4.1
- Node Version: 12.18.4
- NPM Version: >=6.0.0
- Yarn Version: 1.22.4
I have content types posts
(like blog posts) and streaks
(like a number counter) which have no relation, but both separately have a common relation to users
. I want to be able to update the streaks
counter whenever I create a new post
.
I know there are lifecycle hooks like afterCreate
, but correct me if I’m wrong, my (shallow) understanding is that lifecycle hooks can only trigger changes for the specific model of the content type it’s found in (eg lifecycle methods in ./api/{apiName}/models/post.js
can only trigger changes for posts, not other content types). Is that a correct understanding? Happy to be proven wrong tbh!
So is it possible to write a method in ./api/{apiName}/models/post.js
to update the streak
number counter? Would be super grateful for any high level advice or tips!