Print query mongodb to json format

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.