0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/ref.js

20 lines
455 B
JavaScript
Raw Normal View History

2009-07-05 17:51:33 +02: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 22:38:20 +02:00
x.o = new DBPointer( "otherthings" , other._id );
2009-07-05 17:51:33 +02:00
db.things.save(x);
2009-07-06 23:03:03 +02:00
assert( db.things.findOne().o.fetch().n == 1, "dbref broken 2" );
2009-07-05 17:51:33 +02:00
other.n++;
db.otherthings.save(other);
2009-07-06 23:03:03 +02:00
assert( db.things.findOne().o.fetch().n == 2, "dbrefs broken" );