I am having some troubles with DBRef, look this case:
db.fruit.save ({"_id" : "1" , "name" : "apple"});
db.fruit.save ({"_id" : "2" , "name" : "grape"});
db.fruit.save ({"_id" : "3" , "name" : "orange"});
db.fruit.save ({"_id" : "4" , "name" : "pineapple"});
db.basket.save ({"_id" : "1", "items" : [
{"$ref" : "fruit", "$id" : "1", "quantity" : 5},
{"$ref" : "fruit", "$id" : "3", "quantity" : 10}
]})
Now, lets find the "basket" collection:
> db.basket.find ()
{ "_id" : "1", "items" : [
{
"$ref" : "fruit",
"$id" : "1"
},
{
"$ref" : "fruit",
"$id" : "3"
}
] }
The "quantity" attribute disappeared ?! Anybody knows why ? Is there an alternative ?
Thanks.