日期:2014-05-16 浏览次数:20465 次
>show dbs local (empty) > use test > db.test.insert({"TimeStamp":500001,"ProcessID":1001,"ThreadID":2001,"CPU":12}) > db.test.insert({"TimeStamp":500002,"ProcessID":1001,"ThreadID":2001,"CPU":13,"Descreption":"Hello World 2"}) > db.test.insert({"TimeStamp":500003,"ProcessID":1001,"ThreadID":2001,"CPU":13,"Descreption":"Hello World 3"}) > db.test.insert({"TimeStamp":500004,"ProcessID":1001,"ThreadID":2001,"CPU":13,"Descreption":"Hello World 4"}) > db.test.insert({"TimeStamp":500005,"ProcessID":1001,"ThreadID":2001,"CPU":13,"Descreption":"Hello World 5"}) > db.test.insert({"TimeStamp":500006,"ProcessID":1001,"ThreadID":2001,"CPU":13,"Descreption":"Hello World 6"}) >db.test.insert({"TimeStamp":500007,"ProcessID":1001,"ThreadID":2001,"CPU":13,"Descreption":"Hello World 7"}) > db.test.insert({"TimeStamp":500008,"ProcessID":1001,"ThreadID":2001,"CPU":13,"Descreption":"Hello World 8"}) > db.test.insert({"TimeStamp":500009,"ProcessID":1001,"ThreadID":2001,"CPU":13,"Descreption":"Hello World 9"}) > db.test.insert({"TimeStamp":500010,"ProcessID":1001,"ThreadID":2001,"CPU":13,"Descreption":"Hello World 10"})
//列显示用1,不显示用0 > db.test.find({"Descreption":{"$regex":".*1.*"}},{"TimeStamp":1}) { "_id" : ObjectId("4f66a9a2ad4aa301dccb47ab"), "TimeStamp" : 500001 } { "_id" : ObjectId("4f66aa11ad4aa301dccb47b4"), "TimeStamp" : 500010 }
> db.test.find({"Descreption":{"$regex":".*1.*"}},{"TimeStamp":0}) { "_id" : ObjectId("4f66a9a2ad4aa301dccb47ab"), "ProcessID" : 1001, "ThreadID" : 2001, "CPU" : 12, "Descreption" : "Hell o World 1" } { "_id" : ObjectId("4f66aa11ad4aa301dccb47b4"), "ProcessID" : 1001, "ThreadID" : 2001, "CPU" : 13, "Descreption" : "Hell o World 10" } >