Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-1632

improve find with using DBRef to support joins

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None

      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} }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            igo igo
            Votes:
            6 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: