DELETE request: only remove dependent document + add no cascade flag
Changed the DELETE method cascade functionality so it would only delete documents which are dependent on the deleted document.
Also added a new flag to disable this cascading delete: "--no-delete-cascade"
Updated README to explain this functionality and added tests.
This addresses #760, #725, #721, #578, #545
+1
+1
+1
Hi, are there any plans on merging / resolving the conflicts? I know it has been a while since the pr was opened but I am currently struggling with the same issue.
Or is there a workaround I am not aware of?
Kind regards
This bug still happens, any intention/ETA to merge this?
This bug still happens today.
Any chance to merge this ? It is an undocumented behavior that makes some use cases unmanageable ...
+1
+1
Still having this issue. I can use Postman, my own Angular code, and curl. When I delete an unrelated item (ex: http://localhost:3000/items/1001) all items in the entire collection are deleted. I tried --no-cascade-delete to no avail.
Is there a version available that includes these changes?
I use --fsk _id to change de default Id
@MarcoFriz
I use --fsk _id to change de default Id
Thank you Marco. This helps and since i'm not trying to join anything this is fine.
if anyone else needs to add this to their server.js this seems to work
const router = jsonServer.router(path.join(__dirname, "db.json"), { foreginKeySuffix: "_id" });
How can we use --no-cascade-delete in module server.js?
const jsonServer = require('json-server')
const server = jsonServer.create()
const router = jsonServer.router('db.json')
const middlewares = jsonServer.defaults()
server.use(middlewares)
server.use(router)
// server.arguments(--no-delete-cascade)
server.listen(5000, () => {
console.log('JSON Server is running')
})