Open gr0uch opened 9 years ago
Actually, there is. It's maybe not very visible.
You can find tests here: https://github.com/typicode/json-server/blob/master/test/index.js#L294 https://github.com/typicode/json-server/blob/master/test/utils.js#L10
What's the content of your db.json
?
Oh nevermind, I tried it and what I got was unexpected, the comment disappeared! I expected the comment to still exist, but without the postId
property. I should have changed my original post to another example to make it more clear what I mean by referential integrity:
In db.json
is exactly what's in the README, then I make this request:
$ curl -X PATCH -H "Content-Type: application/json" -d '{"postId":2}' http://localhost:3000/comments/1
I expect this request to fail because the post with ID 2 does not exist, but it works anyways and now there is no referential integrity.
That's very good points, thanks :) I'll see what can be done for that.
From my brief inspection of the source code, there is no concept of foreign keys or side effects. For example, if I make this request:
And subsequently make this request:
In the response there is still
postId: 1
, even though it doesn't exist.