Search code examples
node.jsmongodbrestheart

RestHeart Deleting Specific JSON object from Collection


The title explains most of it. I am trying to remove all objects from a collection where {"name": "Steve"} for example but I can't find anything in the documentation on how to achieve this without two separate http requests.

I am using NodeJS with the request library. All I have been able to find as a viable option is to find the ID and delete the object by using that.

Thanks for your help!


Solution

  • You can use a bulk delete request:

    DELETE /db/coll/*?filter={"name":"Steve"}

    Bulk requests have the URI with wildcard document id and include DELETE and PATCH verbs.

    More info at https://softinstigate.atlassian.net/wiki/x/JQBGAQ