MongoDB Export Query results to file examples _mongodb

Source: Internet
Author: User
Tags mongodb

Dump.js

Copy Code code as follows:

var c = db.user.find ({nick_name:{$exists: True, $ne: '}}). limit (100);
while (C.hasnext ()) {
Printjson (C.next ());
}
MONGO 192.168.2.201:41211/dc_user dump.js > Feed.json

The specified data for the user table of the Dc_user library is saved in JSON form in Feed.json.

Note: The Printjson output is formatted JSON text for easy viewing of the data, but cannot be imported with Mongoimport if you need to import replacement Printjson as Printjsononeline.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.