com.foursquare.rogue

Query

case class Query [M, R, +State] (meta: M, collectionName: String, lim: Option[Int], sk: Option[Int], maxScan: Option[Int], comment: Option[String], hint: Option[ListMap[String, Any]], condition: AndCondition, order: Option[MongoOrder], select: Option[MongoSelect[M, R]], readPreference: Option[ReadPreference]) extends Product with Serializable

The definition of methods needed to build a query.

To construct a query, an instance of a query-builder needs to be created. That's done by using an implicit conversion from an instance of a meta-record. In code, the user writes a query by calling one of the query construction methods on an instance of the query-record meta-record instance. The implicit conversion will construct an appropriate query builder from the meta-record.

Query builders are parameterized using a collection of phantom types. For our purposes here, phantom types are types which are inferred by the type system, rather than being explicitly provided by users. The phantom types are inferred by the type system on the basis of what clauses are contained in the query. For example, if there's a ordering clause, that constrains the types so that the type system must infer a type parameter of type "Ordered". This use of phantom types allows the type system to prevent a range of query errors - for example, if two query clauses have incompatible ordering constraints, the type system will reject it.

The specific mechanics of the type inference process are based on implicit parameters. A type can only get inferred into an expression based on a parameter. But we don't want people to have to specify parameters explicitly - that would wreck the syntax. Instead, we use implicit parameters. The inference system will find an implicit parameter that is type compatible with what's used in the rest of the expression.

M

the record type being queried.

R
State

a phantom type which defines the state of the builder.

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Query
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Query (meta: M, collectionName: String, lim: Option[Int], sk: Option[Int], maxScan: Option[Int], comment: Option[String], hint: Option[ListMap[String, Any]], condition: AndCondition, order: Option[MongoOrder], select: Option[MongoSelect[M, R]], readPreference: Option[ReadPreference])

Value Members

  1. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  2. def != (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  5. def == (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  6. def allShards [S2] (implicit ev: com.foursquare.rogue.AddShardAware[State, _, S2]): Query[M, R, S2]

  7. def and [F] (clause: (M) ⇒ QueryClause[F]): Query[M, R, State]

    Adds another and-connected clause to the query.

  8. def andAsc (field: (M) ⇒ com.foursquare.rogue.AbstractQueryField[_, _, _, M])(implicit ev: <:<[State, Ordered]): Query[M, R, State]

  9. def andDesc (field: (M) ⇒ com.foursquare.rogue.AbstractQueryField[_, _, _, M])(implicit ev: <:<[State, Ordered]): Query[M, R, State]

  10. def andOpt [V, F] (opt: Option[V])(clause: (M, V) ⇒ QueryClause[F]): Query[M, R, State]

  11. def asDBObject : DBObject

  12. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  13. def canEqual (arg0: Any): Boolean

    Definition Classes
    Query → Equals
  14. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  15. val collectionName : String

  16. def comment (c: String): Query[M, R, State]

  17. val comment : Option[String]

  18. val condition : AndCondition

  19. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  20. def equals (arg0: Any): Boolean

    Definition Classes
    Query → Equals → AnyRef → Any
  21. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  22. def findAndModify [F] (clause: (M) ⇒ ModifyClause)(implicit ev1: Required[State, Unlimited with Unskipped], ev2: RequireShardKey[M, State]): FindAndModifyQuery[M, R]

  23. def findAndModifyOpt [V] (opt: Option[V])(clause: (M, V) ⇒ ModifyClause)(implicit ev1: Required[State, Unlimited with Unskipped], ev2: RequireShardKey[M, State]): FindAndModifyQuery[M, R]

  24. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef → Any
  25. def hashCode (): Int

    Definition Classes
    Query → AnyRef → Any
  26. def hint (index: MongoIndex[M]): Query[M, R, State]

  27. val hint : Option[ListMap[String, Any]]

  28. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  29. def iscan [F] (clause: (M) ⇒ QueryClause[F]): Query[M, R, State]

    Adds an iscan clause to a query.

  30. def iscanOpt [V, F] (opt: Option[V])(clause: (M, V) ⇒ QueryClause[F]): Query[M, R, State]

  31. val lim : Option[Int]

  32. def limit [S2] (n: Int)(implicit ev: AddLimit[State, S2]): Query[M, R, S2]

    Places a limit on the size of the returned result.

    Places a limit on the size of the returned result.

    Like "or", this uses the Rogue phantom-type/implicit parameter mechanics. To call this method, the query must not yet have a limit clause attached. This is captured by the implicit parameter being constrained to be "Unlimited". After this is called, the type signature of the returned query is updated so that the "MaybeLimited" type parameter is now Limited.

  33. def limitOpt [S2] (n: Option[Int])(implicit ev: AddLimit[State, S2]): Query[M, R, S2]

  34. def maxScan (max: Int): Query[M, R, State]

  35. val maxScan : Option[Int]

  36. val meta : M

  37. def modify (clause: (M) ⇒ ModifyClause)(implicit ev1: Required[State, Unselected with Unlimited with Unskipped], ev2: ShardingOk[M, State]): ModifyQuery[M, State]

  38. def modifyOpt [V] (opt: Option[V])(clause: (M, V) ⇒ ModifyClause)(implicit ev1: Required[State, Unselected with Unlimited with Unskipped], ev2: ShardingOk[M, State]): ModifyQuery[M, State]

  39. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  40. def noop ()(implicit ev1: Required[State, Unselected with Unlimited with Unskipped], ev2: ShardingOk[M, State]): ModifyQuery[M, State]

  41. def not [F] (clause: (M) ⇒ QueryClause[F]): Query[M, R, State]

    Adds a negated clause to the query.

  42. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  43. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  44. def or [S2] (subqueries: (Query[M, R, Ordered with Selected with Limited with Skipped with HasNoOrClause]) ⇒ com.foursquare.rogue.Query[M, R, _]*)(implicit ev: AddOrClause[State, S2]): Query[M, R, S2]

    Chains an "or" subquery to the current query.

    Chains an "or" subquery to the current query.

    The use of the implicit parameter here is key to how the Rogue type checking mechanics work. In order to attach an "or" clause to a query, the query as it exists must not yet have an or-clause. So the implicit parameter, which carries the phantom type information, must be "HasNoOrClause" before this is called. After it's called, you can see that the "MaybeHasOrClause" type parameter is changed, and is now specifically bound to "HasOrClause", rather than to a type variable.

  45. val order : Option[MongoOrder]

  46. def orderAsc [S2] (field: (M) ⇒ com.foursquare.rogue.AbstractQueryField[_, _, _, M])(implicit ev: AddOrder[State, S2]): Query[M, R, S2]

    Like "or", this uses the Rogue phantom-type/implicit parameter mechanics.

    Like "or", this uses the Rogue phantom-type/implicit parameter mechanics. To call this method, the query must not yet have an ordering clause attached. This is captured by the implicit parameter being constrained to be "Unordered". After this is called, the type signature of the returned query is updated so that the "MaybeOrdered" type parameter is now Ordered.

  47. def orderDesc [S2] (field: (M) ⇒ com.foursquare.rogue.AbstractQueryField[_, _, _, M])(implicit ev: AddOrder[State, S2]): Query[M, R, S2]

  48. def orderNaturalAsc [V, S2] (implicit ev: AddOrder[State, S2]): Query[M, R, S2]

    Natural ordering.

    Natural ordering. TODO: doesn't make sense in conjunction with ordering on any other fields. enforce w/ phantom types?

  49. def orderNaturalDesc [V, S2] (implicit ev: AddOrder[State, S2]): Query[M, R, S2]

  50. def productArity : Int

    Definition Classes
    Query → Product
  51. def productElement (arg0: Int): Any

    Definition Classes
    Query → Product
  52. def productIterator : Iterator[Any]

    Definition Classes
    Product
  53. def productPrefix : String

    Definition Classes
    Query → Product
  54. def raw (f: (BasicDBObjectBuilder) ⇒ Unit): Query[M, R, State]

  55. val readPreference : Option[ReadPreference]

  56. def scan [F] (clause: (M) ⇒ QueryClause[F]): Query[M, R, State]

    Adds a scan clause to a query.

  57. def scanOpt [V, F] (opt: Option[V])(clause: (M, V) ⇒ QueryClause[F]): Query[M, R, State]

  58. def select [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M], f6: (M) ⇒ SelectField[F6, M], f7: (M) ⇒ SelectField[F7, M], f8: (M) ⇒ SelectField[F8, M], f9: (M) ⇒ SelectField[F9, M], f10: (M) ⇒ SelectField[F10, M])(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10), S2]

  59. def select [F1, F2, F3, F4, F5, F6, F7, F8, F9, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M], f6: (M) ⇒ SelectField[F6, M], f7: (M) ⇒ SelectField[F7, M], f8: (M) ⇒ SelectField[F8, M], f9: (M) ⇒ SelectField[F9, M])(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, (F1, F2, F3, F4, F5, F6, F7, F8, F9), S2]

  60. def select [F1, F2, F3, F4, F5, F6, F7, F8, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M], f6: (M) ⇒ SelectField[F6, M], f7: (M) ⇒ SelectField[F7, M], f8: (M) ⇒ SelectField[F8, M])(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, (F1, F2, F3, F4, F5, F6, F7, F8), S2]

  61. def select [F1, F2, F3, F4, F5, F6, F7, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M], f6: (M) ⇒ SelectField[F6, M], f7: (M) ⇒ SelectField[F7, M])(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, (F1, F2, F3, F4, F5, F6, F7), S2]

  62. def select [F1, F2, F3, F4, F5, F6, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M], f6: (M) ⇒ SelectField[F6, M])(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, (F1, F2, F3, F4, F5, F6), S2]

  63. def select [F1, F2, F3, F4, F5, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M])(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, (F1, F2, F3, F4, F5), S2]

  64. def select [F1, F2, F3, F4, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M])(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, (F1, F2, F3, F4), S2]

  65. def select [F1, F2, F3, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M])(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, (F1, F2, F3), S2]

  66. def select [F1, F2, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M])(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, (F1, F2), S2]

  67. def select [F1, S2] (f1: (M) ⇒ SelectField[F1, M])(implicit ev: com.foursquare.rogue.AddSelect[State, _, S2]): Query[M, F1, S2]

  68. val select : Option[MongoSelect[M, R]]

  69. def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, CC, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M], f6: (M) ⇒ SelectField[F6, M], f7: (M) ⇒ SelectField[F7, M], f8: (M) ⇒ SelectField[F8, M], f9: (M) ⇒ SelectField[F9, M], f10: (M) ⇒ SelectField[F10, M], create: (F1, F2, F3, F4, F5, F6, F7, F8, F9, F10) ⇒ CC)(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, CC, S2]

  70. def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, F9, CC, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M], f6: (M) ⇒ SelectField[F6, M], f7: (M) ⇒ SelectField[F7, M], f8: (M) ⇒ SelectField[F8, M], f9: (M) ⇒ SelectField[F9, M], create: (F1, F2, F3, F4, F5, F6, F7, F8, F9) ⇒ CC)(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, CC, S2]

  71. def selectCase [F1, F2, F3, F4, F5, F6, F7, F8, CC, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M], f6: (M) ⇒ SelectField[F6, M], f7: (M) ⇒ SelectField[F7, M], f8: (M) ⇒ SelectField[F8, M], create: (F1, F2, F3, F4, F5, F6, F7, F8) ⇒ CC)(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, CC, S2]

  72. def selectCase [F1, F2, F3, F4, F5, F6, F7, CC, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M], f6: (M) ⇒ SelectField[F6, M], f7: (M) ⇒ SelectField[F7, M], create: (F1, F2, F3, F4, F5, F6, F7) ⇒ CC)(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, CC, S2]

  73. def selectCase [F1, F2, F3, F4, F5, F6, CC, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M], f6: (M) ⇒ SelectField[F6, M], create: (F1, F2, F3, F4, F5, F6) ⇒ CC)(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, CC, S2]

  74. def selectCase [F1, F2, F3, F4, F5, CC, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], f5: (M) ⇒ SelectField[F5, M], create: (F1, F2, F3, F4, F5) ⇒ CC)(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, CC, S2]

  75. def selectCase [F1, F2, F3, F4, CC, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], f4: (M) ⇒ SelectField[F4, M], create: (F1, F2, F3, F4) ⇒ CC)(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, CC, S2]

  76. def selectCase [F1, F2, F3, CC, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], f3: (M) ⇒ SelectField[F3, M], create: (F1, F2, F3) ⇒ CC)(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, CC, S2]

  77. def selectCase [F1, F2, CC, S2] (f1: (M) ⇒ SelectField[F1, M], f2: (M) ⇒ SelectField[F2, M], create: (F1, F2) ⇒ CC)(implicit ev: com.foursquare.rogue.AddSelect[State, S2, _]): Query[M, CC, S2]

  78. def selectCase [F1, CC, S2] (f1: (M) ⇒ SelectField[F1, M], create: (F1) ⇒ CC)(implicit ev: com.foursquare.rogue.AddSelect[State, _, S2]): Query[M, CC, S2]

  79. def setReadPreference (r: ReadPreference): Query[M, R, State]

    Set a flag to indicate whether this query should hit primaries or secondaries.

    Set a flag to indicate whether this query should hit primaries or secondaries. This only really makes sense if you're using replica sets. If this field is unspecified, rogue will leave the option untouched, so you'll use secondaries or not depending on how you configure the mongo java driver. Also, this only works if you're doing a query -- findAndModify, updates, and deletes always go to the primaries.

    For more info, see http://www.mongodb.org/display/DOCS/slaveOk

  80. def signature (): String

  81. val sk : Option[Int]

  82. def skip [S2] (n: Int)(implicit ev: AddSkip[State, S2]): Query[M, R, S2]

    Adds a skip to the query.

    Adds a skip to the query.

    Like or, this uses the Rogue phantom-type/implicit parameter mechanics. To call this method, the query must not yet have a skip clause attached. This is captured by the implicit parameter being constrained to be Unskipped. After this is called, the type signature of the returned query is updated so that the MaybeSkipped type parameter is now Skipped.

  83. def skipOpt [S2] (n: Option[Int])(implicit ev: AddSkip[State, S2]): Query[M, R, S2]

  84. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  85. def toString (): String

    Definition Classes
    Query → AnyRef → Any
  86. def wait (): Unit

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

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  89. def where [F] (clause: (M) ⇒ QueryClause[F]): Query[M, R, State]

    Adds a where clause to a query.

  90. def whereOpt [V, F] (opt: Option[V])(clause: (M, V) ⇒ QueryClause[F]): Query[M, R, State]

  91. def withShardKey [F, S2] (clause: (M) ⇒ QueryClause[F] with ShardKeyClause)(implicit ev: com.foursquare.rogue.AddShardAware[State, S2, _]): Query[M, R, S2]

    Adds an eqs clause specifying the shard key.

Deprecated Value Members

  1. def productElements : Iterator[Any]

    Definition Classes
    Product
    Annotations
    @deprecated
    Deprecated

    use productIterator instead

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any