|
please consider improving usage of find with fields parameter specified to handle DBRefs. This can be easy way to do joins automatically like this:
> db.foo.insert({a: 1});
|
> var a = db.foo.findOne();
|
> a
|
{ "_id" : ObjectId("4c67d3ae8d551a734559d73c"), "a" : 1 }
|
> db.foo.insert({b:2, a: new DBRef("foo", a._id)});
|
> var b = db.foo.findOne({b:2});
|
> b
|
{
|
"_id" : ObjectId("4c67d3ee8d551a734559d73d"),
|
"b" : 2,
|
"a" : {
|
"$ref" : "foo",
|
"$id" : ObjectId("4c67d3ae8d551a734559d73c")
|
}
|
}
|
improved find would be able to do this:
> var b = db.foo.findOne({b:2}, {b:1, "a.a": 1});
|
> b
|
{ "_id" : ObjectId("4c67d3ee8d551a734559d73d"), "b" : 2, "a" : { "_id" : ObjectId("4c67d3ae8d551a734559d73c"), "a" : 1} }
|
|