4

My result is given below;

db.userdetail.find({}, {UserName: 1, _id:1}).pretty();

Result:

{ 
    "_id" : ObjectId("572981ddbe0da6156de04167"), 
    "UserName" : "anil"
}

Here how do I change UserName to name and _id to value, is it possible?

chridam
  • 100,957
  • 23
  • 236
  • 235
Pradeep
  • 97
  • 3
  • 9

1 Answers1

-1

You could use mongodb's aggregation framework, although I would not recommend it for big queries (you might hit memory limits) or very common queries (consumes more resources)

lesingerouge
  • 1,160
  • 7
  • 14