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

improve find with using DBRef to support joins

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • None
    • None
    • Querying
    • None

    Description

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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: