Imran_khan
(Imran Khan)
September 16, 2021, 7:43pm
#1
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
I want to get the employee records based on the department collection
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
steevej
(Steeve Juneau)
September 17, 2021, 6:18pm
#3
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.