Giter VIP home page Giter VIP logo

Comments (6)

typicode avatar typicode commented on July 16, 2024

Hi,

Really happy you find it useful :)

Regarding the issue, it's strange that it's inconsistent. Also in the GET route, there's nothing that should delete things.

I'll try to write a test or make manual tests as soon as I can.

You're welcome, thanks for letting me know about this issue.

from json-server.

julienbechade avatar julienbechade commented on July 16, 2024

I'm still debugging so I'll update as soon as I found something if I find something…

from json-server.

typicode avatar typicode commented on July 16, 2024

Cool, thanks :)

from json-server.

julienbechade avatar julienbechade commented on July 16, 2024

So far I found the test case…
On newly created posts when no comments is linked via the postId key, the entire resource gets deleted.

Steps to reproduce:

  • resource posts and comments exists,
  • comments/{i} are tied to posts\{j} via the postId key,
  • create a new post, id of {k} gets attributed,
  • GET /posts/{k}/comments, returns [],
  • GET /comments, returns []

I cannot get to the root of the behaviour yet but I have good hopes…

Cheers.

from json-server.

julienbechade avatar julienbechade commented on July 16, 2024

I found where the problem lies. It's due to the way I'm handling the edit of the data.
When updating, I DELETE all posts items and POST the updated or new items, json-server removes dependents comments on DELETE /posts/{k}, which make kind of sense but not for what I'm trying to achieve…

I'll handle the use case in the client then.

Sorry and thanks for your time.

from json-server.

typicode avatar typicode commented on July 16, 2024

You're welcome, good that you solved your issue :)

from json-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.