I have some updates. I used lifecycle hooks and followed the documentation here: Models - Strapi Developer Docs
In src/api/house/content-types/house/lifecycles.js I added the following code:
module.exports = {
beforeCreate(event) {
const { data } = event.params;
data.title = `${data.bed} bed / ${data.bath} bath / ${data.rent} USD a month`;
},
beforeUpdate(event) {
const { data } = event.params;
data.title = `${data.bed} bed / ${data.bath} bath / ${data.rent} USD a month`;
}
}
What if I wanted to also extract something from a relation? For e.g. house_type, the problem is that right now if I do ${data.house_type} it returns an ID. How do I get the actual title from that relation?