2016-03-09 12:17:50 -05:00
|
|
|
// to run:
|
2010-03-29 09:36:16 -07:00
|
|
|
// ./mongo jstests/ref3.js
|
2009-10-02 17:07:07 -04:00
|
|
|
|
2010-03-29 09:36:16 -07:00
|
|
|
db.otherthings3.drop();
|
|
|
|
|
db.things3.drop();
|
2009-10-02 17:07:07 -04:00
|
|
|
|
2016-05-28 17:55:12 -04:00
|
|
|
var other = {s: "other thing", n: 1};
|
2010-03-29 09:36:16 -07:00
|
|
|
db.otherthings3.save(other);
|
2009-10-02 17:07:07 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
db.things3.save({name: "abc"});
|
2010-03-29 09:36:16 -07:00
|
|
|
x = db.things3.findOne();
|
2016-03-09 12:17:50 -05:00
|
|
|
x.o = new DBRef("otherthings3", other._id);
|
2010-03-29 09:36:16 -07:00
|
|
|
db.things3.save(x);
|
2009-10-02 17:07:07 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert(db.things3.findOne().o.fetch().n == 1, "dbref broken 2");
|
2009-10-02 17:07:07 -04:00
|
|
|
|
|
|
|
|
other.n++;
|
2010-03-29 09:36:16 -07:00
|
|
|
db.otherthings3.save(other);
|
2016-03-09 12:17:50 -05:00
|
|
|
assert(db.things3.findOne().o.fetch().n == 2, "dbrefs broken");
|