-
Type: New Feature
-
Resolution: Done
-
Priority: Major - P3
-
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();
> var another =
{ s : "another thing", n : 2};
> db.otherthings.save(another);
> db.otherthings.find();
> 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 )];
> db.things.save(mongo);
> db.things.findOne().otherthings.fetchAll();
{"_id" : "497dab624ee47b3a675d2d9c" , "name" : "mongo" , "type" : "database" , "data" :
, "otherthings" : [
{"_id" : "497dbcb36b27d59a708e89a4" , "s" : "other thing" , "n" : 1},
{"_id" : "4a7aabf13240ba3080db97dd" , "s" : "another thing" , "n" : 2}] }