System Information
- Strapi Version: 4.21.1
- Operating System: Windows 10
- Database: SQL Lite
- Node Version: 20.10
- NPM Version: 10.4
- Yarn Version:
Hello, community
I have a one-way relation that points entries in a Socio collection-type to fees in the Fee collection type.
Every time a new Socio is created I want to create a new Fee and point the new Socio to this fee by using the afterCreate lifecycles hook.
This is what I’ve tried so far in the Socio lifecycles script:
async afterCreate(event) {
const newFee = await strapi.entityService.create("api::fee.fee", {
data: {
name: event.params.data.nome,
publishedAt: Date.now(),
},
});
await strapi.entityService.update(
"api::socio.socio",
event.params.data.id,
{
populate: {
fee: true,
},
data: {
fee: newFee.id,
},
}
);
}
However, I get the following 500 error and the relation isn’t established (the fee is created though):
“error: Undefined binding(s) detected when compiling WHERE. Undefined column(s): [t0.id] query: where t0
.id
= ?”
This topic follws this one: https://forum.strapi.io/t/automatically-create-related-content-type/40100
Thank you!