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

14 lines
412 B
JavaScript
Raw Normal View History

2009-10-02 23:07:07 +02:00
2010-01-04 20:23:12 +01:00
a = db.dbref2a;
b = db.dbref2b;
2009-10-02 23:07:07 +02:00
a.drop();
b.drop();
a.save( { name : "eliot" } );
2010-01-04 20:23:12 +01:00
b.save( { num : 1 , link : new DBRef( "dbref2a" , a.findOne()._id ) } );
2009-10-02 23:07:07 +02:00
assert.eq( "eliot" , b.findOne().link.fetch().name , "A" );
2009-11-06 20:38:40 +01:00
assert.eq( 1 , b.find( function(){ return this.link.fetch().name == "eliot"; } ).count() , "B" );
assert.eq( 0 , b.find( function(){ return this.link.fetch().name == "el"; } ).count() , "C" );