mongodb查询部分满足条件的列

db.tblorders.createIndex( { orderid : -1 },{background:true, name:"index_orderid"} );

db.orderlog.dropIndex("index_id");


db.orderlog.find().max({name:"larry"}).

use admin;

db.runCommand(
{
renameCollection:"jinri.tblorders_20141111",
to: "jinri.tblorders",
dropTarget: false
}
);





db.orderlog.find({},{oid:1,"orderno":1,"createtime":1}).sort({"oid" : -1}).limit(1);

db.orderlog.createIndex( { oid : 1 },{background:true, name:"index_oid"} );


---查询按照OID倒序只查询oid,orderno,createtime字段并返回2行即可

db.orderlog.find({},{"_id":0,"oid":1,"orderno":1,"createtime":1}).sort({"oid":-1}).limit(2);


db.orderlog.find({"oid":"73099840"});


---查询部分列并且只查询满足条件的部分列
db.OrderLog201512.find({},{"_id":0,oid:1,"orderno":1,"createtime":1},{"orderno" : "20151123010022979562"}).limit(1).forEach(printjson);

你可能感兴趣的:(mongodb部分列)