问题
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