2 * A class representation of the BSON DBRef type.
5 * @param {string} namespace the collection name.
6 * @param {ObjectID} oid the reference ObjectID.
7 * @param {string} [db] optional db name, if omitted the reference is local to the current db.
10 function DBRef(namespace, oid, db) {
11 if(!(this instanceof DBRef)) return new DBRef(namespace, oid, db);
13 this._bsontype = 'DBRef';
14 this.namespace = namespace;
23 DBRef.prototype.toJSON = function() {
25 '$ref':this.namespace,
27 '$db':this.db == null ? '' : this.db
31 module.exports = DBRef;
32 module.exports.DBRef = DBRef;