Files
mongo/jstests/core/ref3.js

20 lines
446 B
JavaScript
Raw Normal View History

// to run:
// ./mongo jstests/ref3.js
2009-10-02 17:07:07 -04: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};
db.otherthings3.save(other);
2009-10-02 17:07:07 -04:00
db.things3.save({name: "abc"});
x = db.things3.findOne();
x.o = new DBRef("otherthings3", other._id);
db.things3.save(x);
2009-10-02 17:07:07 -04:00
assert(db.things3.findOne().o.fetch().n == 1, "dbref broken 2");
2009-10-02 17:07:07 -04:00
other.n++;
db.otherthings3.save(other);
assert(db.things3.findOne().o.fetch().n == 2, "dbrefs broken");