Im using feathers socket.io client.
Can not remove items with foreign keys, even with cascade : true option.
I do that:
client.service('schedule').remove(this.sid, {
cascade: true
}).then(() => ...
This is throws an error:
type: "FeathersError", name: "BadRequest", message: "update or delete on table \"schedule\" violates foreign key constraint \"meetups_sessionId_fkey\" on table \"meetups\""
I try do that:
client.service('schedule').remove(this.sid, {
query: {
cascade: true
}
}).then(() => {...
It throws an error:
Object { type: "FeathersError", name: "GeneralError", message: "column schedule.cascade does not exist",
In services multi option is set on true
You must delete query.cascade after using it so that it does not go into the query to the DB.
You must delete
query.cascadeafter using it so that it does not go into the query to the DB.
This is throws an error like this:
type: "FeathersError", name: "BadRequest", message: "update or delete on table \"schedule\" violates foreign key constraint \"meetups_sessionId_fkey\" on table \"meetups\""
There is no cascade option by default in any of the adapters. It is database specific, if you are e.g. using Sequelize it would have to be in params.sequelize in a before hook.
I thought of something like this:
```js
app.service('schedule').hooks({
before: {
remove: async context => {
const otherService = context.app.service('other');
await otherService.remove(null, { query: { /**/ } });
delete context.params.query.cascade;
return context;
}
}
});
Thanks for answers, problem was been solved.
Most helpful comment
Thanks for answers, problem was been solved.