this is sample way how to print query mongodb to json format

mongo –host IP_address/dbname -u user_name -p password –eval ‘printjson(Query_mongo)’ > output.json

mongo --host 192.168.10.20/products -u ericks -p januari2017 --eval 'printjson(db.getCollection('transaction_shares').find({transaction_time: {$lt: ISODate("2016-12-07"),$gte: ISODate("2016-12-01")}},{_id: 0, transaction_id: 1, variables: 1, transaction_time: 1}))' > query_products.json

hope this article help you

Advertisements