Files
mongo/jstests/ref.js

20 lines
455 B
JavaScript
Raw Normal View History

2009-07-05 11:51:33 -04:00
// to run:
// ./mongo jstests/ref.js
db.otherthings.drop();
db.things.drop();
var other = { s : "other thing", n : 1};
db.otherthings.save(other);
db.things.save( { name : "abc" } );
x = db.things.findOne();
2009-10-02 16:38:20 -04:00
x.o = new DBPointer( "otherthings" , other._id );
2009-07-05 11:51:33 -04:00
db.things.save(x);
2009-07-06 17:03:03 -04:00
assert( db.things.findOne().o.fetch().n == 1, "dbref broken 2" );
2009-07-05 11:51:33 -04:00
other.n++;
db.otherthings.save(other);
2009-07-06 17:03:03 -04:00
assert( db.things.findOne().o.fetch().n == 2, "dbrefs broken" );