DBRef

public struct DBRef: ValueConvertible

DBRef is a structure made to keep references to other MongoDB objects and resolve them easily

  • The collection this referenced Document resides in

    Declaration

    Swift

    public var collection: Collection
  • id

    The referenced Document’s _id

    Declaration

    Swift

    public var id: BSON.Primitive
  • Converts this DBRef to a BSON.Primitive for easy embedding

    Declaration

    Swift

    public func makePrimitive() -> BSON.Primitive
  • Creates a DBRef

    Declaration

    Swift

    public init(referencing reference: BSON.Primitive, inCollection collection: Collection)
  • Initializes this DBRef with a Primitive.

    This initializer fails when the Primitive isn’t a valid DBRef Document

    Declaration

    Swift

    public init?(_ primitive: Primitive?, inServer server: Server)
  • Initializes this DBRef with a Primitive.

    This initializer fails when the Primitive isn’t a valid DBRef Document

    Declaration

    Swift

    public init?(_ primitive: Primitive?, inDatabase database: Database)
  • Initializes this DBRef with a Document.

    This initializer fails when the Document isn’t a valid DBRef Document

    Declaration

    Swift

    public init?(_ document: Document, inServer server: Server)
  • Initializes this DBRef with a Document.

    This initializer fails when the Document isn’t a valid DBRef Document

    Declaration

    Swift

    public init?(_ document: Document, inDatabase database: Database)
  • The Document representation of this DBRef

    Declaration

    Swift

    public var documentValue: Document
  • Resolves this reference to a Document

    Declaration

    Swift

    public func resolve() throws -> Document?

    Return Value

    The Document or nil if the reference is invalid or the Document has been removed.