I’m trying to update a field in one of my component after save is hit. My code runs, however it hits an error but the changes do take effect and the frontend says Warning internal server error. First I wanted to check if my code is correct (been hearing about infinite loops with afterUpdate and entityService update) and second, address the error. Thanks
const { data, populate } = event.params;
const id = data.id;
const entries = await strapi.entityService.findMany(
"api::deep-dive-tile.deep-dive-tile",
{
populate: populate,
}
);
function updateLabels(data) {
data?.project?.individualRecords.forEach((record) => {
record.label = record.card.title;
});
return data;
}
const updatedData = updateLabels(entries);
await strapi.entityService.update("api::deep-dive-tile.deep-dive-tile", id, {
data: {
project: updatedData.project,
},
});
},```
Error:
```Error: Undefined binding(s) detected when compiling WHERE. Undefined column(s): [t0.id] query: where "t0"."id" = ?
at QueryCompiler_PG.toSQL (/usr/src/app/node_modules/knex/lib/query/querycompiler.js:112:13)
at compileCallback (/usr/src/app/node_modules/knex/lib/formatter/formatterUtils.js:13:19)
at rawOrFn (/usr/src/app/node_modules/knex/lib/formatter/wrappingFormatter.js:225:7)
at QueryCompiler_PG.whereWrapped (/usr/src/app/node_modules/knex/lib/query/querycompiler.js:1095:17)
at QueryCompiler_PG.where (/usr/src/app/node_modules/knex/lib/query/querycompiler.js:584:34)
at /usr/src/app/node_modules/knex/lib/query/querycompiler.js:135:40
at Array.forEach (<anonymous>)
at QueryCompiler_PG.select
at QueryBuilder_PostgreSQL.toSQL (/usr/src/app/node_modules/knex/lib/query/querybuilder.js:84:44)
[2024-05-23 21:49:26.719] http: PUT /content-manager/single-types/api::deep-dive-tile.deep-dive-tile/ (124 ms) 500```
<i>This topic has been created from a Discord post (1243321537356894320) to give it more visibility.
It will be on Read-Only mode here.
<a href="https://discord.com/channels/811989166782021633/1243321537356894320/1243321537356894320">Join the conversation on Discord</a></i>