telefonicaid / fiware-orion

Context Broker and CEF building block for context data management, providing NGSI interfaces.
https://fiware-orion.rtfd.io/
GNU Affero General Public License v3.0
212 stars 265 forks source link

How can I delete an entire entity by specifying the type? #4311

Open houka2023 opened 1 year ago

houka2023 commented 1 year ago

Orion centex broker can add and update, but I think there is a need to delete naturally, but it is nonsense if there is none

fgalan commented 1 year ago

Not sure of understanding want you mean... Do you mean that Orion should implement and API request to delete all entities of a given type?

(By the moment I'm going to remove the "bug" label as this doesn't seem to be a bug but a feature request)

houka2023 commented 1 year ago

sorry . actually it's not a bug but a feature request . i mean how can i delete entire entity of a given type. and other entity of type are not be deleted. for example There is a need to delete more than a thousand record of entity, now we can only delete entity by id. we have to foreach more then 1000 times to delete the entity。too inefficient。

fgalan commented 1 year ago

I understand your "feature request" will be solved by https://github.com/telefonicaid/fiware-orion/issues/2389 (using idPattern: .* with a given type). Thus, I'd suggest to close this issue.

Btw, note #2389 has been labeled with "help wanted" so everybody is welcome to contribute with a solution for it in the form of pull request :)

On the meanwhile, this script could helpfull: https://github.com/telefonicaid/fiware-orion/blob/master/scripts/utils/delete_attribute_by_query.py. You can use a filter like this:

filter = '&type=<the type you want to delete>'

The script is old and it has not been migrated to work with Python 3 (it works with Python 2.7) but it would be easy to fix. In that case, if would be great if you could please contribute with the Python 3 version to the repository.