Http://www.linuxidc.com/Linux/2011-08/41043.htm
Dbrefis a more formal specification for creating references between documents. DBRefs (generally) include a collection name as well as a object ID. Most developers DBRefs if the collection can change from one document to the next. If your referenced collection'll always be the same, the manual references outlined above is more efficient. ^_^ [root@:/usr/Local/mongodb/bin]#./mongo mongodb Shell version:1.8.2 connecting to: Test > var a = {name: "C + +"} > DB Test ; Db.language.save (a) > Db.language.find () {"_id": ObjectId ("4da32c897d2de864e0448e06"), "name": "C + +"} > VA R B = {name: "JavaScript"} > Db.language.save (b) > Db.language.find () {"_id": ObjectId ("4da32c897d2de864e0448e06"), "Nam E ":" C + + "} {" _id ": ObjectId (" 4da32cb17d2de864e0448e07 ")," name ":" JavaScript "} > LAN = {name: "Obj1", Computer:[new dbref (' language ', a._id)]} { "name" : "obj1", " Computer " : [ { "$ref" : "language", "$id" : objectid ("4da32c897d2de864e0448e06") } ] } > lan.computer[0] { "$ref" : "Language", "$id" : objectid ("4da32c897d2de864e0448e06") } > Lan.computer[0].Fetch() {"_id": ObjectId ("4da32c897d2de864e0448e06"), "name": "C + +"} > Db.language.Insert(LAN) > db.language.find () { "_id" : objectid ("4da32c897d2de864e0448e06"), "Name" : "C + +" } { "_id" : objectid ("4da32cb17d2de864e0448e07") , "Name" : "JavaScript" } { "_id" : objectid (" 4da33b487d2de864e0448e08 "), " name " : " obj1 ", " Computer " : [ { " $ref " : "Language", "$id" &nbsP;: objectid ("4da32c897d2de864e0448e06") } ] } > db.language.findone ({ name: "Obj1"}). Computer[0].Fetch() {"_id": ObjectId ("4da32c897d2de864e0448e06"), "name": "c+ + "} > lan2 = {name: "Obj2", Computer:[new dbref (' language ', b._id)]} { "name" : "Obj2", "Computer" : [ { "$ref"  : "Language", "$id" : objectid (" 4da32cb17d2de864e0448e07 ") } ] } > db.language.Insert(lan2) > Db.language.find () {"_id": ObjectId ("4da32c897d2de864e0448e06"), "name": "C + +"} {"_id": ObjectId (" 4da32cb17d2de864e0448e07 ")," name ":" JavaScript "} {" _id ": ObjectId (" 4da33b487d2de864e0448e08 ")," name ":" Obj1 "," Co Mputer ": [{" $ref ":" Language "," $id ": ObjectId (" 4da32c897d2de864e0448e06 ")}]}