Packages

  • package root

    This is the documentation for the MongoDB Scala driver.

    This is the documentation for the MongoDB Scala driver.

    Driver structure

    The mongodb scala driver.

    To get started you need a MongoClient instance, either from a connection string or via a org.mongodb.scala.MongoClientSettings.

    Notable packages include:

    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package mongodb
    Definition Classes
    org
  • package scala

    The MongoDB Scala Driver package

    The MongoDB Scala Driver package

    Contains type aliases and companion objects to help when using the Scala API

    Definition Classes
    mongodb
    Since

    1.0

  • package bson

    The bson package, contains mirrors and companion objects for Bson values.

    The bson package, contains mirrors and companion objects for Bson values.

    Definition Classes
    scala
  • object DefaultHelper

    A helper containing the sealed DefaultsTo trait which is used to determine the default type for a given method.

    A helper containing the sealed DefaultsTo trait which is used to determine the default type for a given method.

    Attributes
    protected[scala]
    Definition Classes
    bson
    Since

    1.0

  • DefaultsTo
  • LowPriorityDefaultsTo

sealed class DefaultsTo[A, B] extends AnyRef

Neat helper to obtain a default type should one not be given eg:

def find[T]()(implicit e: T DefaultsTo Document) { ... }

The signature of the find method ensures that it can only be called if the caller can supply an object of type DefaultsTo[T, Document]. Of course, the DefaultsTo.default and DefaultsTo.overrideDefault methods make it easy to create such an object for any type T. Since these methods are implicit, the compiler automatically handles the business of calling one of them and passing the result into find.

But how does the compiler know which method to call? It uses its type inference and implicit resolution rules to determine the appropriate method. There are three cases to consider:

1. find is called with no type parameter. In this case, type T must be inferred. Searching for an implicit method that can provide an object of type DefaultsTo[T, Document], the compiler finds default and overrideDefault. default is chosen since it has priority (because it's defined in a proper subclass of the trait that defines overrideDefault). As a result, T must be bound to Document.

2. find is called with a non-Document type parameter (e.g., find[BsonDocument]()). In this case, an object of type DefaultsTo[BsonDocument, Document] must be supplied. Only the overrideDefault method can supply it, so the compiler inserts the appropriate call.

3. find is called with Document as the type parameter. Again, either method is applicable, but default wins due to its higher priority.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. DefaultsTo
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new DefaultsTo()

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  13. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  14. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  15. def toString(): String
    Definition Classes
    AnyRef → Any
  16. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  17. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  18. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped