Skip to content

DELETE request: only remove dependent document + add no cascade flag #756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

liorcode
Copy link

@liorcode liorcode commented Apr 4, 2018

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

liorcode added 3 commits April 4, 2018 16:39
Change 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 and tests.

This addresses typicode#725, typicode#721, typicode#578, typicode#545
seems the previous style was valid for node 4 but not 8.
this style seems to work for both.
@rotem-hen
Copy link

+1

@dazulu
Copy link

dazulu commented Jun 1, 2018

+1

@ascendantofrain
Copy link

+1

@felixcolaci
Copy link

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

@ayxos
Copy link

ayxos commented Nov 8, 2019

This bug still happens, any intention/ETA to merge this?

@Zhouqchao
Copy link

This bug still happens today.

@neich
Copy link

neich commented Apr 14, 2020

Any chance to merge this ? It is an undocumented behavior that makes some use cases unmanageable ...

@jonatasrossi
Copy link

+1

1 similar comment
@BrenoMazieiro
Copy link

+1

@SheldonHage
Copy link

SheldonHage commented Feb 19, 2021

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.

@fhanggi
Copy link

fhanggi commented Mar 5, 2021

Is there a version available that includes these changes?

@MarcoFriz
Copy link

I use --fsk _id to change de default Id

@fhanggi
Copy link

fhanggi commented Apr 14, 2022

@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" });

@SilverSeva
Copy link

SilverSeva commented May 25, 2022

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')
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.