class Mongo::DBRef
Represents a DBRef document in the database.
@since 2.1.0
Constants
- COLLECTION
-
The constant for the collection reference field.
@since 2.1.0
- DATABASE
-
The constant for the database field.
@since 2.1.0
- ID
-
The constant for the id field.
@since 2.1.0
Attributes
@return [ String ] collection The collection name.
@return [ String ] database The database name.
@return [ BSON::ObjectId ] id The referenced document id.
Public Class Methods
Source
# File lib/mongo/dbref.rb, line 71 def initialize(collection, id, database = nil) @collection = collection @id = id @database = database end
Public Instance Methods
Source
# File lib/mongo/dbref.rb, line 55 def as_json(*args) document = { COLLECTION => collection, ID => id } document.merge!(DATABASE => database) if database document end
Source
# File lib/mongo/dbref.rb, line 88 def to_bson(buffer = BSON::ByteBuffer.new, validating_keys = BSON::Config.validating_keys?) as_json.to_bson(buffer) end