可以的,将投射过的字段在结果中重命名:
原始数据:db.zipcode.find()
{ "_id" : "01001", "city" : "AGAWAM", "loc" : [ -72.622739, 42.070206 ], "pop" : 15338, "state" : "MA" }
{ "_id" : "01002", "city" : "AGAWAM", "loc" : [ -72.51565, 42.377017 ], "pop" : 36963, "state" : "MA" }
{ "_id" : "01005", "city" : "AGAWAM", "loc" : [ -72.108354, 42.409698 ], "pop" : 4546, "state" : "MA" }
{ "_id" : "01007", "city" : "BELCHERTOWN", "loc" : [ -72.410953, 42.275103 ], "pop" : 10579, "state" : "MA" }
{ "_id" : "01008", "city" : "BLANDFORD", "loc" : [ -72.936114, 42.182949 ], "pop" : 1240, "state" : "MA" }
显示原字段和重命名字段名称:db.zipcode.aggregate({$project:{myid:"$_id"}})
{ "_id" : "01001", "myid" : "01001" }
{ "_id" : "01002", "myid" : "01002" }
{ "_id" : "01005", "myid" : "01005" }
{ "_id" : "01007", "myid" : "01007" }
{ "_id" : "01008", "myid" : "01008" }
只显示重命名字段名称:db.zipcode.aggregate({$project:{myid:"$_id",_id:0}})
{ "myid" : "01001" }
{ "myid" : "01002" }
{ "myid" : "01005" }
{ "myid" : "01007" }
{ "myid" : "01008" }