Search code examples
loopbackjs

Delete all the row that matches a filter


How can I delete all the row that matchs a specific filter ?

Something like

DELETE /items?filter={"where":{"color":"blue"}}

Solution

  • You could refer to the loopback documentation to delete persisted model and filter

    In your NODE code

    Books.destroyAll({"or":[{"id":1},{"id":2}]}, callback)
    

    In your REST API

    http://localhost:3000/api/Books?filter={"where":{"or":[{"id":1},{"id":2}]}}
    

    If you update your question with the code that is not working for you, I could update the answer to address your problem.