kestra-io / plugin-mongodb

https://kestra.io/plugins/plugin-mongodb/
Apache License 2.0
4 stars 5 forks source link

No example input file provided - Unable to run task with Bulk command #3

Open shrutimantri opened 9 months ago

shrutimantri commented 9 months ago

Expected Behavior

Successfully running the example given here: https://kestra.io/plugins/tasks/io.kestra.plugin.mongodb.Bulk

Actual Behaviour

The flow example of type: "io.kestra.plugin.mongodb.Bulk"mentioned in this page uses an input file in this line: from: "{{ inputs.file }}"

But it is not clear exactly what this file should contain. It is unclear as to how to represent the operations and the command in this file. Without this information, I am unable to run this exanmple.

Note: The other MongoDB commands where input file is required is a json file containing the documents. But this one is a special case as we also need to put in the operation details along with the document.

Steps To Reproduce

Trying to run the flow example:

id: "bulk"
type: "io.kestra.plugin.mongodb.Bulk"
connection:
  uri: "mongodb://root:example@localhost:27017/?authSource=admin"
database: "my_database"
collection: "my_collection"
from: "{{ inputs.file }}"

Environment Information

Example flow

id: "bulk"
type: "io.kestra.plugin.mongodb.Bulk"
connection:
  uri: "mongodb://root:example@localhost:27017/?authSource=admin"
database: "my_database"
collection: "my_collection"
from: "{{ inputs.file }}"
cedrelek commented 7 months ago

The file must have bulk operations, as explained here : https://www.mongodb.com/docs/manual/reference/method/db.collection.bulkWrite/

For exemple a ion file (do not start the file with an array symbol "[") :

{ "insertOne" : { "document" : "<document>" } }
{ "updateOne" : {
  "filter": "<document>",
  "update": "<document or pipeline>",
  "upsert": "<boolean>",
  "collation": "<document>",               
  "arrayFilters": [ "<filterdocument1>" ],
  "hint": "<document/string>"    
  }
}