-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
DELETE call deletes all the entries. #13
Comments
Actually, JSON-Server deletes dependent resources. For example, if you delete a post, it will delete comments that are associated with the post. To do so, JSON-Server will look at the database and remove entries that references other entries that don't exist (based on the parentId property). This is why all your posts got deleted. They are referencing users that don't exist. To fix it, you can either remove the ̀userId` property or add an users table like this: {
"users": [
{ "id": 1 },
{ "id": 2 }
],
"posts": {
// ...
}
} Tell me if it solvers your problem? |
Worked like a charm. |
Hello, just a quick note for anyone having such issues : {
"id": 1,
"postId": "PI524"
} will be deleted every time, instead, align values : {
"id": "PI524",
"postId": "PI524"
}
|
what if I need to relate items like (questions - answers ) with form ID and each one should have its own id also @aboudard |
I am providing json file as a db source containing post elements as in : https://gist.github.com/injulkarnilesh/4cfd42501bfd5c13885f
Rest of the calls work fine
GET /posts/
GET /posts/3
POST /posts/
These calls work as expected.
But on
DELETE /posts/3
Response says
Response does not contain any data.
with status 204.
and json data in the file gets emptied to
{
"posts": []
}
Shouldn't it delete only the mentioned post rather than all the posts?
The text was updated successfully, but these errors were encountered: