def to_bson(buffer = BSON::ByteBuffer.new, validating_keys = BSON::Config.validating_keys?)
      as_json.to_bson(buffer)
    end
def to_bson(buffer = BSON::ByteBuffer.new, validating_keys = BSON::Config.validating_keys?)
      as_json.to_bson(buffer)
    end
Instantiate a new DBRef.

 @example Create the DBRef.
   Mongo::DBRef.new('users', id, 'database')

 @param [ String ] collection The collection name.
 @param [ BSON::ObjectId ] id The object id.
 @param [ String ] database The database name.

 @since 2.1.0
 Converts the DBRef to raw BSON.

 @example Convert the DBRef to raw BSON.
   dbref.to_bson

 @param [ BSON::ByteBuffer ] buffer The encoded BSON buffer to append to.
 @param [ true, false ] validating_keys Whether keys should be validated when serializing.

 @return [ String ] The raw BSON.

 @since 2.1.0