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

Array.fetchRefs( colName ) ( WAS : db.col.findOne().val.fetchAll() for lists of DBRefs )

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.1.2
    • Affects Version/s: None
    • Component/s: None
    • None

      The shell provides a way to fetch a DBRef'd document into the current one. It would be very useful to be able to do this on a list/array value - each document in an array which looks like a DBRef is fetched into the current doc. An example to illustrate the concept:

      > var other =

      { s : "other thing", n : 1}

      ;
      > db.otherthings.save(other);
      > db.otherthings.find();

      {"_id" : "497dbcb36b27d59a708e89a4" , "s" : "other thing" , "n" : 1}

      > var another =

      { s : "another thing", n : 2}

      ;
      > db.otherthings.save(another);
      > db.otherthings.find();

      {"_id" : "4a7aabf13240ba3080db97dd" , "s" : "another thing" , "n" : 2}

      > var mongo = db.things.findOne();
      > print(tojson(mongo));
      {"_id" : "497dab624ee47b3a675d2d9c" , "name" : "mongo" , "type" : "database" , "data" : {"a" : 1 , "b" : 2}}
      > mongo.otherthings = [new DBRef( 'otherthings' , other._id ), new DBRef( 'otherthings' , another._id )];

      {"s" : "other thing" , "n" : 1 , "_id" : "497dbcb36b27d59a708e89a4"}

      > db.things.save(mongo);
      > db.things.findOne().otherthings.fetchAll();
      {"_id" : "497dab624ee47b3a675d2d9c" , "name" : "mongo" , "type" : "database" , "data" :

      {"a" : 1 , "b" : 2}

      , "otherthings" : [

      {"_id" : "497dbcb36b27d59a708e89a4" , "s" : "other thing" , "n" : 1}

      ,

      {"_id" : "4a7aabf13240ba3080db97dd" , "s" : "another thing" , "n" : 2}

      ] }

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            digitala Phillip Oldham
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: