那位大师知道用 find 操作mongodb库的时候,如何对字段重命名, 如:
> db.Foods.findOne();
{
"name" : "锛圙IF 鍥惧儚锛?6x11 鍍忕礌锛?gif",
"imgUrl" : "2012_11_17锛圙IF 鍥惧儚锛?6x11 鍍忕礌锛?gif",
"money" : "10",
"source" : "C",
"address" : "涓浗娴嬭瘯",
"time" : 1355748279000,
"_id" : ObjectId("50cf13b7abbfa2041d000001")
}
不知道为没有方法 把_id修改为id输出(或是 把time修改为mytime),我希望得到的结果如下:
{
"name" : "锛圙IF 鍥惧儚锛?6x11 鍍忕礌锛?gif",
"imgUrl" : "2012_11_17锛圙IF 鍥惧儚锛?6x11 鍍忕礌锛?gif",
"money" : "10",
"source" : "C",
"address" : "涓浗娴嬭瘯",
"mytime" : 1355748279000,
**"id" : ObjectId("50cf13b7abbfa2041d000001")**
}
感觉有点像操作数据的sql语句
select mytime time form Foods
17 回复