Class Mongo::DBRef
In: lib/mongo/dbref.rb
Parent: Object

Represents a DBRef document in the database.

@since 2.1.0

Methods

as_json   new   to_bson  

Included Modules

BSON::JSON

Classes and Modules

Module Mongo::DBRef::ClassMethods

Constants

COLLECTION = '$ref'.freeze   The constant for the collection reference field.

@since 2.1.0

ID = '$id'.freeze   The constant for the id field.

@since 2.1.0

DATABASE = '$db'.freeze   The constant for the database field.

@since 2.1.0

Attributes

collection  [R]  @return [ String ] collection The collection name.
database  [R]  @return [ String ] database The database name.
id  [R]  @return [ BSON::ObjectId ] id The referenced document id.

Public Class methods

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

Public Instance methods

Get the DBRef as a JSON document

@example Get the DBRef as a JSON hash.

  dbref.as_json

@return [ Hash ] The max key as a JSON hash.

@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

[Validate]