Mongoexport using different collection in query

Hi Team,

Is there any option in mongoexport to use the query on different collection

mongoexport --host=“xxx:1111” --db=dbname --pretty --collection=employee --query=‘db.department.find({“departmentId”:10},{“employeeID”:1})’ --out=output.json

  1. I want to get the employee records based on the department collection
  2. All the employee , those who belong to deparmentID : 10

Db version details
db.version();
4.2.8

Hi @Imran_khan, I am not sure if I am getting your query correctly but are you trying to join two different collections and export the data?

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
MongoDB

For complex scenarios like your you might want to use one of the driver or mongosh to implement your logic. This way you have access to the aggregation framework. It should be easy to write a small client that implements your logic and prints to file.