Apache-Nifi : Delete MongoDB collections

偶尔善良 提交于 2019-12-24 22:00:45

问题


I want to delete some collections : db['mycollection'].remove({}) ,of my MongoDB database, i found out that there is a deleteMongo processor but i don't know how to use it since i can't find examples.

So, does deleteMongo processor allow to do this? if it does, can you show me an example please.

Thanks in advance!


回答1:


The DeleteMongo doesn't actually delete collections, rather it deletes the documents in the provided collection. Take a look at the processor's documentation here. It expects the incoming FlowFile to have the query as its content. A quick example you could try is:

GenerateFlowFile -> DeleteMongo

Configure GenerateFlowFile and provide a MongoDB query, something like { "customer.name" : "Smith, John"} and connect it to DeleteMongo. You have to configure DeleteMongo with the database name, connection string and collection name.

Having said that, it may not suit your requirement of dropping collections, but technically you can wipe the entire collection of documents from the configured collection, if your query is {} and the Delete Mode of DeleteMongo processor is set to Delete Many



来源:https://stackoverflow.com/questions/50873069/apache-nifi-delete-mongodb-collections

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!