json-server icon indicating copy to clipboard operation
json-server copied to clipboard

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

Open liorcode opened this issue 8 years ago • 14 comments

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 avatar Apr 04 '18 13:04 liorcode

+1

rotem-hen avatar Apr 04 '18 15:04 rotem-hen

+1

dazulu avatar Jun 01 '18 11:06 dazulu

+1

ascendantofrain avatar Aug 08 '18 17:08 ascendantofrain

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

felixcolaci avatar Mar 18 '19 20:03 felixcolaci

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

ayxos avatar Nov 08 '19 07:11 ayxos

This bug still happens today.

Zhouqchao avatar Mar 31 '20 09:03 Zhouqchao

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

neich avatar Apr 14 '20 16:04 neich

+1

jonatasrossi avatar Jun 15 '20 15:06 jonatasrossi

+1

BrenoMazieiro avatar Jun 15 '20 15:06 BrenoMazieiro

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.

SheldonHage avatar Feb 19 '21 23:02 SheldonHage

Is there a version available that includes these changes?

fhanggi avatar Mar 05 '21 20:03 fhanggi

I use --fsk _id to change de default Id

MarcoFriz avatar Apr 13 '22 21:04 MarcoFriz

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

fhanggi avatar Apr 14 '22 01:04 fhanggi

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

SilverSeva avatar May 25 '22 07:05 SilverSeva