Skip to content
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

[Improvement][V1] Delete all entities for a given type #1645

Open
alexd6631 opened this issue Jan 6, 2016 · 12 comments
Open

[Improvement][V1] Delete all entities for a given type #1645

alexd6631 opened this issue Jan 6, 2016 · 12 comments
Labels

Comments

@alexd6631
Copy link

In order to run automatic integration testing of an app using Orion CB, it would be useful to be able to delete all entities (for instance before installing fixtures), so the test can run in a deterministic environment.

In V1 it is not possible to delete multiple entities in a single operation

POST /v1/updateContext HTTP/1.1
Content-Type: application/json
Accept: application/json

{
    "contextElements": [
        {
            "type": "MyEntity",
            "isPattern": "true",
            "id": ".*"
        }
    ],
    "updateAction": "DELETE"
} 

Fails with

{
  "contextResponses": [
    {
      "contextElement": {
        "type": "MyEntity",
        "isPattern": "true",
        "id": ".*"
      },
      "statusCode": {
        "code": "501",
        "reasonPhrase": "Not Implemented"
      }
    }
  ]
}
@fgalan fgalan added the backlog label Jan 8, 2016
@fgalan
Copy link
Member

fgalan commented Jan 8, 2016

Thank for the feedback. We acknowledgue this issue as part of our backlog (note the "backlog" label) and eventually we will deal with it.

On the meanwhile, a workaround (easy to implement in integrated testing) is to cleanup the Orion DB entities collection before each test, e.g.;

echo 'db.entities.remove({})' | mongo orion --quiet

@fgalan
Copy link
Member

fgalan commented Jan 8, 2016

(Semi offtopic: note that "*" is not a valid pattern as it is not a valid regex, i.e. * is a qualifier meaning "zero or more" which only makes sense when prefixed by a characters. I understand that you probably wanted to use ".*" which measn "zero or more times any character").

@jmcanterafonseca
Copy link
Contributor

+1 to this feature. I would suggest adding to v2 API features

@fgalan
Copy link
Member

fgalan commented Jan 25, 2016

+1 to this feature. I would suggest adding to v2 API features

It has been explicetly mentioned in the issue about NGSIv2 POST /v2/op/update operation (see #1715).

@fgalan
Copy link
Member

fgalan commented Sep 29, 2016

This issue is related with #1503, which is more general about updates using id pattern for entities.

@fgalan
Copy link
Member

fgalan commented Sep 29, 2016

The following SOF question may need update after completing this issue: http://stackoverflow.com/questions/39732799/orion-context-broker-delete-several-entities-at-one-call/39776195#39776195

@gtorodelvalle
Copy link
Member

Definitely a +1 :)

@cdupont
Copy link

cdupont commented Oct 25, 2017

+1

@fgalan
Copy link
Member

fgalan commented Dec 19, 2017

The following SOF question has to be updated after completing this issue: https://stackoverflow.com/questions/47889912/fiware-orion-remove-all-entities-of-the-same-type

@fgalan
Copy link
Member

fgalan commented Mar 7, 2018

The following script can be useful to delete all entities (of a given type and/or matching a given filter) while this issue gets implemented: https://github.com/telefonicaid/fiware-orion/blob/master/scripts/utils/delete_entities.py

@cdupont
Copy link

cdupont commented May 18, 2019

I was wondering about the status? Thanks.

@fgalan
Copy link
Member

fgalan commented May 20, 2019

No news as far as I know. The issue is waiting a brave developer to take care of it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants