Class

reactivemongo.api.collections.QueryBuilderFactory

QueryBuilder

Related Doc: package QueryBuilderFactory

Permalink

final class QueryBuilder extends AnyRef

A builder that helps to make a fine-tuned query to MongoDB.

When the query is ready, you can call cursor to get a Cursor, or one if you want to retrieve just one document.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. QueryBuilder
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from (QueryBuilderFactory.this)#QueryBuilder to any2stringadd[(QueryBuilderFactory.this)#QueryBuilder] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): ((QueryBuilderFactory.this)#QueryBuilder, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from (QueryBuilderFactory.this)#QueryBuilder to ArrowAssoc[(QueryBuilderFactory.this)#QueryBuilder] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. def allowPartialResults: (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the partial flag.

    Sets the partial flag.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def allowPartial(c: BSONCollection) =
      c.find(BSONDocument.empty).allowPartialResults
  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. def awaitData: (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Makes the result cursor await data.

    Makes the result cursor await data.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def waitData(c: BSONCollection) =
      c.find(BSONDocument.empty).awaitData
  9. def batchSize(n: Int): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the size of result batches.

    Sets the size of result batches.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def tenBatch(c: BSONCollection) =
      c.find(BSONDocument.empty).batchSize(10)
  10. val batchSize: Int

    Permalink

    the upper limit on the number of documents to retrieve per batch (0 for unspecified)

  11. lazy val builder: Builder[(QueryBuilderFactory.this)#pack.type]

    Permalink
  12. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  13. def collation(collation: Collation): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the collation document.

    Sets the collation document.

    Since

    MongoDB 3.4

    import reactivemongo.api.Collation
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    def foo(coll: BSONCollection, c: Collation) =
      coll.find(BSONDocument.empty).collation(c)
  14. val collation: Option[Collation]

    Permalink

    the optional collation to use for the find command (default: None) {@since MongoDB 3.4}

    the optional collation to use for the find command (default: None) {@since MongoDB 3.4}

    import scala.concurrent.{ ExecutionContext, Future }
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    def firstFirst(coll: BSONCollection)(
      implicit ec: ExecutionContext): Future[Option[BSONDocument]] = {
      val queryBuilder = coll.find(BSONDocument.empty)
      queryBuilder.one[BSONDocument]
    }
  15. def comment(message: String): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Adds a comment to this query, that may appear in the MongoDB logs.

    Adds a comment to this query, that may appear in the MongoDB logs.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) = coll.find(BSONDocument.empty).
      comment("Any comment to trace the query")
  16. val comment: Option[String]

    Permalink

    the query comment

  17. def cursor[T](readPreference: ReadPreference = readPreference)(implicit reader: P.Reader[T], cp: CursorProducer[T]): ProducedCursor

    Permalink

    Returns a Cursor for the result of this query.

    Returns a Cursor for the result of this query.

    import scala.concurrent.{ ExecutionContext, Future }
    
    import reactivemongo.api.Cursor
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def findAllVisible(coll: BSONCollection)(
      implicit ec: ExecutionContext): Future[List[BSONDocument]] =
      coll.find(BSONDocument("visible" -> true)).
        cursor[BSONDocument]().collect[List](
         maxDocs = 10,
         err = Cursor.FailOnError[List[BSONDocument]]())
    T

    the results type

    readPreference

    The reactivemongo.api.ReadPreference for this query. If the ReadPreference implies that this query can be run on a secondary, the slaveOk flag will be set.

    reader

    the reader for the results type

  18. val cursorOptions: CursorOptions

    Permalink

    the cursor options

  19. def ensuring(cond: ((QueryBuilderFactory.this)#QueryBuilder) ⇒ Boolean, msg: ⇒ Any): (QueryBuilderFactory.this)#QueryBuilder

    Permalink
    Implicit information
    This member is added by an implicit conversion from (QueryBuilderFactory.this)#QueryBuilder to Ensuring[(QueryBuilderFactory.this)#QueryBuilder] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  20. def ensuring(cond: ((QueryBuilderFactory.this)#QueryBuilder) ⇒ Boolean): (QueryBuilderFactory.this)#QueryBuilder

    Permalink
    Implicit information
    This member is added by an implicit conversion from (QueryBuilderFactory.this)#QueryBuilder to Ensuring[(QueryBuilderFactory.this)#QueryBuilder] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  21. def ensuring(cond: Boolean, msg: ⇒ Any): (QueryBuilderFactory.this)#QueryBuilder

    Permalink
    Implicit information
    This member is added by an implicit conversion from (QueryBuilderFactory.this)#QueryBuilder to Ensuring[(QueryBuilderFactory.this)#QueryBuilder] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  22. def ensuring(cond: Boolean): (QueryBuilderFactory.this)#QueryBuilder

    Permalink
    Implicit information
    This member is added by an implicit conversion from (QueryBuilderFactory.this)#QueryBuilder to Ensuring[(QueryBuilderFactory.this)#QueryBuilder] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  23. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  24. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  25. def exhaust: (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the flag to return all data returned by the query at once rather than splitting the results into batches.

    Sets the flag to return all data returned by the query at once rather than splitting the results into batches.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def ex(c: BSONCollection) =
      c.find(BSONDocument.empty).exhaust
  26. def explain(flag: Boolean = true): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Toggles explain mode.

    Toggles explain mode.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) = coll.find(BSONDocument.empty).explain()
  27. val explain: Boolean

    Permalink

    the explain flag

  28. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  29. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from (QueryBuilderFactory.this)#QueryBuilder to StringFormat[(QueryBuilderFactory.this)#QueryBuilder] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  30. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  31. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  32. def hint(h: (QueryBuilderFactory.this)#Hint): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the hint document (a document that declares the index MongoDB should use for this query).

    Sets the hint document (a document that declares the index MongoDB should use for this query).

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) = coll.find(BSONDocument.empty).
      hint(coll.hint(BSONDocument("foo" -> 1))) // sets the hint
  33. val hint: Option[(QueryBuilderFactory.this)#Hint]

    Permalink

    the index to “hint” or force MongoDB to use when performing the query.

  34. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  35. def max(document: P.Document): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the max document.

    Sets the max document.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) = coll.find(BSONDocument.empty).
      max(BSONDocument("field" -> "maxValue"))
  36. val max: Option[P.Document]

    Permalink

    the optional exclusive upper bound for a specific index (default: None)

  37. def maxAwaitTimeMs(milliseconds: Long): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Adds maxAwaitTimeMs to query.

    Adds maxAwaitTimeMs to query.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) =
      coll.find(BSONDocument.empty).maxAwaitTimeMs(1000L) // 1s
  38. val maxAwaitTimeMs: Option[Long]

    Permalink
  39. def maxScan(max: Double): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the maxScan flag.

    Sets the maxScan flag.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) = coll.find(BSONDocument.empty).
      maxScan(1.23D)
  40. val maxScan: Option[Double]

    Permalink

    this option specifies a maximum number of documents or index keys the query plan will scan.

  41. def maxTimeMs(milliseconds: Long): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Adds maxTimeMs to query.

    Adds maxTimeMs to query.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) =
      coll.find(BSONDocument.empty).maxTimeMs(1000L) // 1s
  42. val maxTimeMs: Option[Long]

    Permalink

    the maximum execution time

  43. def min(document: P.Document): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the min document.

    Sets the min document.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) = coll.find(BSONDocument.empty).
      min(BSONDocument("field" -> "minValue"))
  44. val min: Option[P.Document]

    Permalink

    the optional exclusive lower bound for a specific index (default: None)

  45. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  46. def noCursorTimeout: (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the noTimeout flag.

    Sets the noTimeout flag.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def acceptTimeout(c: BSONCollection) =
      c.find(BSONDocument.empty).noCursorTimeout
  47. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  48. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  49. def one[T](readPreference: ReadPreference)(implicit reader: P.Reader[T], ec: ExecutionContext): Future[Option[T]]

    Permalink

    Sends this query and gets a future Option[T] (alias for reactivemongo.api.Cursor.headOption).

    Sends this query and gets a future Option[T] (alias for reactivemongo.api.Cursor.headOption).

    import scala.concurrent.{ ExecutionContext, Future }
    
    import reactivemongo.api.ReadPreference
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def findUser(coll: BSONCollection, name: String)(
      implicit ec: ExecutionContext): Future[Option[BSONDocument]] =
      coll.find(BSONDocument("user" -> name)).
        one[BSONDocument](ReadPreference.primaryPreferred)
    T

    the results type

    readPreference

    The reactivemongo.api.ReadPreference for this query. If the ReadPreference implies that this query can be run on a secondary, the slaveOk flag will be set.

    reader

    the reader for the results type

  50. def one[T](implicit reader: P.Reader[T], ec: ExecutionContext): Future[Option[T]]

    Permalink

    Sends this query and gets a future Option[T] (alias for reactivemongo.api.Cursor.headOption) (using the default reactivemongo.api.ReadPreference).

    Sends this query and gets a future Option[T] (alias for reactivemongo.api.Cursor.headOption) (using the default reactivemongo.api.ReadPreference).

    import scala.concurrent.{ ExecutionContext, Future }
    
    import reactivemongo.api.bson.{ BSONDocument, Macros }
    import reactivemongo.api.bson.collection.BSONCollection
    
    case class User(name: String, pass: String)
    
    implicit val handler = Macros.reader[User]
    
    def findUser(coll: BSONCollection, name: String)(
      implicit ec: ExecutionContext): Future[Option[User]] =
      coll.find(BSONDocument("user" -> name)).one[User]
    T

    the results type

    reader

    the reader for the results type

  51. def projection[Pjn](p: Pjn)(implicit writer: P.Writer[Pjn]): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the projection specification to determine which fields to include in the returned documents.

    Sets the projection specification to determine which fields to include in the returned documents.

    import scala.concurrent.{ ExecutionContext, Future }
    
    import reactivemongo.api.Cursor
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def findAllWithProjection(coll: BSONCollection)(
      implicit ec: ExecutionContext): Future[List[BSONDocument]] =
      coll.find(BSONDocument.empty).
        projection(BSONDocument("age" -> 1)). // only consider 'age' field
        cursor[BSONDocument]().
        collect[List](
          maxDocs = 100,
          err = Cursor.FailOnError[List[BSONDocument]]())
    Pjn

    The type of the projection. An implicit Writer[Pjn] typeclass for handling it has to be in the scope.

  52. def projection(document: P.Document): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the projection specification to determine which fields to include in the returned documents.

  53. val projection: Option[P.Document]

    Permalink

    the projection specification

  54. def readConcern(concern: ReadConcern): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the ReadConcern.

    Sets the ReadConcern.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) = coll.find(BSONDocument.empty).
      readConcern(reactivemongo.api.ReadConcern.Local)
  55. val readConcern: ReadConcern

    Permalink

    the read concern {@since MongoDB 3.6}

  56. def requireOne[T](readPreference: ReadPreference)(implicit reader: P.Reader[T], ec: ExecutionContext): Future[T]

    Permalink

    Sends this query and gets a future T (alias for reactivemongo.api.Cursor.head).

    Sends this query and gets a future T (alias for reactivemongo.api.Cursor.head).

    import scala.concurrent.{ ExecutionContext, Future }
    
    import reactivemongo.api.ReadPreference
    import reactivemongo.api.bson.{ BSONDocument, Macros }
    import reactivemongo.api.bson.collection.BSONCollection
    
    case class User(name: String, pass: String)
    
    implicit val handler = Macros.handler[User]
    
    def findUser(coll: BSONCollection, name: String)(
      implicit ec: ExecutionContext): Future[User] =
      coll.find(BSONDocument("user" -> name)).
        requireOne[User](ReadPreference.primaryPreferred)
    T

    the results type

    readPreference

    The reactivemongo.api.ReadPreference for this query. If the ReadPreference implies that this query can be run on a secondary, the slaveOk flag will be set.

    reader

    the reader for the results type

  57. def requireOne[T](implicit reader: P.Reader[T], ec: ExecutionContext): Future[T]

    Permalink

    Sends this query and gets a future T (alias for reactivemongo.api.Cursor.head) (using the default reactivemongo.api.ReadPreference).

    Sends this query and gets a future T (alias for reactivemongo.api.Cursor.head) (using the default reactivemongo.api.ReadPreference).

    import scala.concurrent.{ ExecutionContext, Future }
    
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def findUser(coll: BSONCollection, name: String)(
      implicit ec: ExecutionContext): Future[BSONDocument] =
      coll.find(BSONDocument("user" -> name)).requireOne[BSONDocument]
    T

    the results type

    reader

    the reader for the results type

  58. def returnKey(flag: Boolean = true): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the returnKey flag.

    Sets the returnKey flag.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) = coll.find(BSONDocument.empty).returnKey()
  59. val returnKey: Boolean

    Permalink

    if this flag is true, returns only the index keys in the resulting documents

  60. def showRecordId(flag: Boolean = true): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the showRecordId flag.

    Sets the showRecordId flag.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) =
      coll.find(BSONDocument.empty).showRecordId()
  61. val showRecordId: Boolean

    Permalink

    the flags to determines whether to return the record identifier for each document

  62. def singleBatch(flag: Boolean = true): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the singleBatch flag.

    Sets the singleBatch flag.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) = coll.find(BSONDocument.empty).
      singleBatch()
  63. val singleBatch: Boolean

    Permalink

    the flag to determines whether to close the cursor after the first batch (default: false)

  64. def skip(n: Int): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets how many documents must be skipped at the beginning of the results.

    Sets how many documents must be skipped at the beginning of the results.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def skipTen(c: BSONCollection) =
      c.find(BSONDocument.empty).skip(10)
  65. val skip: Int

    Permalink

    the number of documents to skip.

  66. def slaveOk: (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Allows querying of a replica slave (slaveOk).

    Allows querying of a replica slave (slaveOk).

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def makeSlaveOk(c: BSONCollection) =
      c.find(BSONDocument.empty).slaveOk
  67. def snapshot(flag: Boolean = true): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Toggles snapshot mode.

    Toggles snapshot mode.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) = coll.find(BSONDocument.empty).snapshot()
  68. val snapshot: Boolean

    Permalink

    the snapshot flag

  69. def sort(document: P.Document): (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Sets the sort specification for the ordering of the results.

    Sets the sort specification for the ordering of the results.

    import scala.concurrent.{ ExecutionContext, Future }
    
    import reactivemongo.api.Cursor
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def findSortedVisible(coll: BSONCollection)(
      implicit ec: ExecutionContext): Future[List[BSONDocument]] =
      coll.find(BSONDocument("visible" -> true)).
        sort(BSONDocument("age" -> 1)). // sort per age
        cursor[BSONDocument]().
        collect[List](
          maxDocs = 100,
          err = Cursor.FailOnError[List[BSONDocument]]())
  70. val sort: Option[P.Document]

    Permalink

    the optional sort specification

  71. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  72. def tailable: (QueryBuilderFactory.this)#QueryBuilder

    Permalink

    Makes the result cursor tailable.

    Makes the result cursor tailable.

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def ensureTailable(c: BSONCollection) =
      c.find(BSONDocument.empty).tailable
  73. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  74. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  75. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  76. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  77. def [B](y: B): ((QueryBuilderFactory.this)#QueryBuilder, B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from (QueryBuilderFactory.this)#QueryBuilder to ArrowAssoc[(QueryBuilderFactory.this)#QueryBuilder] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from (QueryBuilderFactory.this)#QueryBuilder to any2stringadd[(QueryBuilderFactory.this)#QueryBuilder]

Inherited by implicit conversion StringFormat from (QueryBuilderFactory.this)#QueryBuilder to StringFormat[(QueryBuilderFactory.this)#QueryBuilder]

Inherited by implicit conversion Ensuring from (QueryBuilderFactory.this)#QueryBuilder to Ensuring[(QueryBuilderFactory.this)#QueryBuilder]

Inherited by implicit conversion ArrowAssoc from (QueryBuilderFactory.this)#QueryBuilder to ArrowAssoc[(QueryBuilderFactory.this)#QueryBuilder]

Ungrouped