MongoDB common commands 3 rookie left dish

Leaving the dish novice


index:
db.baidu.ensureIndex ({ "Phone":}. 1);
db.baidu.indexes.find ();



db.c1.find ({X: { '$ EXISTS': to true} , B: { '$ EXISTS':} to true, attr: 2});
db.phone.find ({ "139xy.reg": { '$ EXISTS':}} to false);
db.phone.find ({ " 139xy.reg ":" 1 "});
db.baidu.find ({" baidu.sex ":." 1 "}) COUNT (); // set all the display Baidu sex = 1

// query whether the keys presence
db.baidu.find ({ "baidu.sex": { '$ eXISTS':}} to false);
db.baidu.find ({ "baidu.sex": { '$ eXISTS':}} to false);
 
$ --host localhost --port 27017 --username mongoexport --password QuickTest QuickTest QuickTest --collection trans.sp --db --out trans.sp.json

// export data
-h: Specify the database host IP
-u: specifies the database user name
-p: specifies the database password
-d: specifies the name of the database
-c: specify the collection's name
-f: specify the columns that you want to export
-o: specify the name of the file you want to export to
-q: filtering conditions specified export data

mongoexport -h 127.0.0.1 -d phone -c phone --csv - Phone F, sina.nick, sina.address -o phone.dat
mongoexport -H 127.0.0.1 -d -f Phone Phone -C Phone --csv, sina.nick, sina.address -q "{\" xyqb.reg \ ": \". 1 \ "}" -o phone.csv
mongoexport -H 127.0.0.1 -d -f --csv Phone Phone Phone -C -p "{\" xyqb.reg \ ": \". 1 \ " } "the Z -o: \ the src \ 0.qb \ DATAl \ xyqb.2017-5-21.csv
mongoexport -H 127.0.0.1 -d -f Phone Phone -C Phone --csv, {" baidu.nick "} -p "{ 'baidu.sex': { '$ EXISTS':}} to false" -o the Z: \ the src \ 1.baidu \ baidu_nonick.2017-5-23.csv
mongoexport -H -d baidu 127.0.0.1 - c baidu --csv -f phone, baidu.nick -q '{ "baidu.sex":{"$exists":false}}' -o Z:\src\1.baidu\baidu_nonick.2017-5-23.csv
mongoexport -h 127.0.0.1 -d baidu -c baidu --csv -f phone, baidu.nick -q "{\" baidu.sex \ ": {\" $ exists \ ": false}}" -o Z: \ src \ 1.baidu \ baidu_nonick.2017-5-23.csv
mongoexport -d -h 127.0.0.1 baidu baidu --csv is -c -f Phone, baidu.nick -q {\ "baidu.sex \": { \ "$ EXISTS \": false}} -o the Z-: \ src \ 1.baidu \ baidu_nonick.2017-5-23.csv
mongoexport -h 127.0.0.1 baidu -d -c -f Phone --csv is baidu, baidu .nick -q {{ "baidu.city": ""}, \ "baidu.sex \": {\ "$ exists \": true}} -o Z: \ src \ 1.baidu \ tieba_bsgs.csv

inquiry Beijing, Shanghai, Guangzhou, Shenzhen phone number nicknames
db.baidu.find (
{
    "and $": [
        {
            "baidu.sex": {
                "$ EXISTS": true
            }
        },
        {
            "$or":[
                {
                    "Baidu.city": "Beijing"
                },
                {
                    "baidu.city": "Shanghai"
                },
                {
                    "baidu.city": "Guangzhou"
                },
 {
                    "baidu.city": "Shenzhen"
                }
            ]
        }
    ]
}
) .limit (10) .pretty ();



export Beijing, Shanghai, Guangzhou, Shenzhen has a nickname phone number
mongoexport -h 127.0.0.1 -d baidu -c baidu --csv -f phone,baidu.nick -q {\"$and\":[{\"baidu.sex\":{\"$exists\":true}},{\"$or\":[{\"baidu.city\":\"北京\"},{\"baidu.city\":\"上海\"},{\"baidu.city\":\"广州\"},{\"baidu.city\":\"深圳\"}]}]} -o Z:\src\1.baidu\tieba_bsgs.csv

Guess you like

Origin www.cnblogs.com/iTaoqi/p/11022137.html