salat.dao

ModelCompanion

trait ModelCompanion[ObjectType <: AnyRef, ID] extends BaseDAOMethods[ObjectType, ID] with Logging

Play framework style model companion

package model

import salat.annotations._
import com.mongodb.casbah.Imports._
import salat.dao.{ SalatDAO, ModelCompanion }

object MyModel extends ModelCompanion[MyModel, ObjectId] {
  val collection = MongoConnection()("my_db")("my_model_coll")
  val dao = new SalatDAO[MyModel, ObjectId](collection = collection) {}
}

case class MyModel(@Key("_id") id: ObjectId,
                   x: String,
                   y: Int,
                   z: List[Double])
ObjectType

type of object to be serialized

ID

type of object id to be serialized

Linear Supertypes
Logging, BaseDAOMethods[ObjectType, ID], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ModelCompanion
  2. Logging
  3. BaseDAOMethods
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def dao: DAO[ObjectType, ID]

Concrete Value Members

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

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

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

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

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

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def count(q: com.mongodb.casbah.Imports.DBObject, fieldsThatMustExist: List[String] = Nil, fieldsThatMustNotExist: List[String] = Nil, rp: com.mongodb.casbah.Imports.ReadPreference = defaultReadPreference): Long

    Count the number of documents matching the search criteria.

    Count the number of documents matching the search criteria.

    q

    object for which to search

    fieldsThatMustExist

    list of field keys that must exist

    fieldsThatMustNotExist

    list of field keys that must not exist

    rp

    read preference to use for this search

    returns

    count of documents matching the search criteria

    Definition Classes
    ModelCompanionBaseDAOMethods
  9. def defaultReadPreference: ReadPreference

    In the absence of a specified read preference, supplies a default read preference.

    In the absence of a specified read preference, supplies a default read preference.

    returns

    default read preference for all find and count operations.

    Definition Classes
    ModelCompanionBaseDAOMethods
  10. def defaultWriteConcern: WriteConcern

    In the absence of a specified write concern, supplies a default write concern.

    In the absence of a specified write concern, supplies a default write concern.

    returns

    default write concern to use for insert, update, save and remove operations

    Definition Classes
    ModelCompanionBaseDAOMethods
  11. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  13. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. def find[A, B](ref: A, keys: B, rp: com.mongodb.casbah.Imports.ReadPreference = defaultReadPreference)(implicit arg0: (A) ⇒ com.mongodb.casbah.Imports.DBObject, arg1: (B) ⇒ com.mongodb.casbah.Imports.DBObject): SalatMongoCursor[ObjectType]

    A

    type view bound to DBObject

    B

    type view bound to DBObject

    ref

    object for which to search

    keys

    fields to return

    rp

    read preference to use for this search

    returns

    a typed cursor to iterate over results

    Definition Classes
    ModelCompanionBaseDAOMethods
  15. def find[A, B](ref: A, keys: B)(implicit arg0: (A) ⇒ DBObject, arg1: (B) ⇒ DBObject): SalatMongoCursor[ObjectType]

    Queries for an object in this collection.

    Queries for an object in this collection.

    A

    type view bound to DBObject

    B

    type view bound to DBObject

    ref

    object for which to search

    keys

    fields to return

    returns

    a typed cursor to iterate over results

    Definition Classes
    BaseDAOMethods
  16. def find[A](ref: A)(implicit arg0: (A) ⇒ DBObject): SalatMongoCursor[ObjectType]

    Queries for an object in this collection.

    Queries for an object in this collection.

    A

    type view bound to DBObject

    ref

    object for which to search

    returns

    a typed cursor to iterate over results

    Definition Classes
    BaseDAOMethods
  17. def findAll(): SalatMongoCursor[ObjectType]

    returns

    (Iterator[ObjectType]) iterable result cursor of everything in the collection

  18. def findAndModify[A, B](q: A, sort: B, t: ObjectType)(implicit arg0: (A) ⇒ com.mongodb.casbah.Imports.DBObject, arg1: (B) ⇒ com.mongodb.casbah.Imports.DBObject): Option[ObjectType]

    Finds the first document in the query (sorted) and updates it.

    Finds the first document in the query (sorted) and updates it.

    q

    query to match

    sort

    sort to apply before picking first document

    t

    object with which to modify q

    returns

    (Option[ObjectType]) Some() of the old document, or None if no such object exists

    Definition Classes
    ModelCompanionBaseDAOMethods
  19. def findAndModify[A](q: A, t: ObjectType)(implicit arg0: (A) ⇒ com.mongodb.casbah.Imports.DBObject): Option[ObjectType]

    Performs a find and update operation.

    Performs a find and update operation.

    q

    search query to find and modify

    t

    object with which to modify q

    returns

    (Option[ObjectType]) Some() of the object found (before, or after, the update)

    Definition Classes
    ModelCompanionBaseDAOMethods
  20. def findOne[A](t: A, rp: com.mongodb.casbah.Imports.ReadPreference = defaultReadPreference)(implicit arg0: (A) ⇒ com.mongodb.casbah.Imports.DBObject): Option[ObjectType]

    A

    type view bound to DBObject

    t

    object for which to search

    rp

    read preference to use for this search

    returns

    (Option[ObjectType]) Some() of the object found, or None if no such object exists

    Definition Classes
    ModelCompanionBaseDAOMethods
  21. def findOne[A](t: A)(implicit arg0: (A) ⇒ DBObject): Option[ObjectType]

    Returns a single object from this collection.

    Returns a single object from this collection.

    A

    type view bound to DBObject

    t

    object for which to search

    returns

    (Option[ObjectType]) Some() of the object found, or None if no such object exists

    Definition Classes
    BaseDAOMethods
  22. def findOneById(id: ID): Option[ObjectType]

    id

    identifier

    returns

    (Option[ObjectType]) Some() of the object found, or None if no such object exists

    Definition Classes
    ModelCompanionBaseDAOMethods
  23. def fromJSON(s: String): ObjectType

    s

    string representing a valid JSON object

    returns

    JSON deserialized to a model object

  24. def fromJSON(j: JObject): ObjectType

    j

    JObject to be deserialized

    returns

    JObject deserialized to a model object

  25. def fromJSONArray(s: String): List[ObjectType]

    s

    string representing a JSON array of valid JObjects

    returns

    deserialized list of model objects

  26. def fromJSONArray(j: JArray): List[ObjectType]

    j

    JSON array of valid JObjects

    returns

    deserialized list of model objects

  27. def fromMap(m: Map[String, Any]): ObjectType

    m

    a map populated with the field names and values of the model object

    returns

    model object instance

  28. final def getClass(): Class[_]

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

    Definition Classes
    AnyRef → Any
  30. def ids[A](query: A)(implicit arg0: (A) ⇒ com.mongodb.casbah.Imports.DBObject): List[ID]

    A

    type view bound to DBObject

    query

    query

    returns

    list of IDs

    Definition Classes
    ModelCompanionBaseDAOMethods
  31. def insert(t: ObjectType, wc: com.mongodb.casbah.Imports.WriteConcern): Option[ID]

    t

    instance of ObjectType

    wc

    write concern

    returns

    if insert succeeds, ID of inserted object

    Definition Classes
    ModelCompanionBaseDAOMethods
  32. def insert(docs: Traversable[ObjectType], wc: com.mongodb.casbah.Imports.WriteConcern): List[Option[ID]]

    docs

    collection of ObjectType instances to insert

    wc

    write concern

    returns

    list of object ids TODO: flatten list of IDs - why on earth didn't I do that in the first place?

    Definition Classes
    ModelCompanionBaseDAOMethods
  33. def insert(docs: ObjectType*)(implicit wc: WriteConcern): List[Option[ID]]

    Inserts a group of documents into the database.

    Inserts a group of documents into the database.

    docs

    variable length argument of ObjectType instances

    returns

    if write concern succeeds, a list of object IDs TODO: this implicit: dumbest design decision on the face of the planet? TODO: replace vararg with traversable TODO: flatten list of IDs - why on earth didn't I do that in the first place?

    Definition Classes
    BaseDAOMethods
  34. def insert(t: ObjectType): Option[ID]

    Inserts a document into the database.

    Inserts a document into the database.

    t

    instance of ObjectType

    returns

    if insert succeeds, ID of inserted object

    Definition Classes
    BaseDAOMethods
  35. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  36. lazy val log: Logger

    Attributes
    protected
    Definition Classes
    Logging
  37. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  38. final def notify(): Unit

    Definition Classes
    AnyRef
  39. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  40. def primitiveProjection[P](query: com.mongodb.casbah.Imports.DBObject, field: String)(implicit m: Manifest[P], ctx: Context): Option[P]

    P

    type of projected field

    query

    object for which to search

    field

    field to project on

    m

    implicit manifest typed to P

    ctx

    implicit salat.Context

    returns

    (Option[P]) Some() of the object found, or None if no such object exists

    Definition Classes
    ModelCompanionBaseDAOMethods
  41. def primitiveProjections[P](query: com.mongodb.casbah.Imports.DBObject, field: String)(implicit m: Manifest[P], ctx: Context): List[P]

    P

    type of projected field

    query

    object for which to search

    field

    field to project on

    m

    implicit manifest typed to P

    ctx

    implicit salat.Context

    returns

    (List[P]) of the objects found

    Definition Classes
    ModelCompanionBaseDAOMethods
  42. def projection[P <: CaseClass](query: com.mongodb.casbah.Imports.DBObject, field: String)(implicit m: Manifest[P], ctx: Context): Option[P]

    P

    type of projected field

    query

    object for which to search

    field

    field to project on

    m

    implicit manifest typed to P

    ctx

    implicit salat.Context

    returns

    (Option[P]) Some() of the object found, or None if no such object exists

    Definition Classes
    ModelCompanionBaseDAOMethods
  43. def projections[P <: CaseClass](query: com.mongodb.casbah.Imports.DBObject, field: String)(implicit m: Manifest[P], ctx: Context): List[P]

    P

    type of projected field

    query

    object for which to search

    field

    field to project on

    m

    implicit manifest typed to P

    ctx

    implicit salat.Context

    returns

    (List[P]) of the objects found

    Definition Classes
    ModelCompanionBaseDAOMethods
  44. def remove[A](q: A, wc: com.mongodb.casbah.Imports.WriteConcern)(implicit arg0: (A) ⇒ com.mongodb.casbah.Imports.DBObject): com.mongodb.casbah.Imports.WriteResult

    A
    q

    the object that documents to be removed must match

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    ModelCompanionBaseDAOMethods
  45. def remove(t: ObjectType, wc: com.mongodb.casbah.Imports.WriteConcern = defaultWriteConcern): com.mongodb.casbah.Imports.WriteResult

    t

    object to remove from the collection

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    ModelCompanionBaseDAOMethods
  46. def remove[A](q: A)(implicit arg0: (A) ⇒ DBObject): com.mongodb.casbah.Imports.WriteResult

    Removes objects from the database collection.

    Removes objects from the database collection.

    q

    the object that documents to be removed must match

    returns

    (WriteResult) result of write operation

    Definition Classes
    BaseDAOMethods
  47. def remove(t: ObjectType): com.mongodb.casbah.Imports.WriteResult

    Remove a matching object from the collection

    Remove a matching object from the collection

    t

    object to remove from the collection

    returns

    (WriteResult) result of write operation

    Definition Classes
    BaseDAOMethods
  48. def removeById(id: ID, wc: com.mongodb.casbah.Imports.WriteConcern = defaultWriteConcern): com.mongodb.casbah.Imports.WriteResult

    id

    the ID of the document to be removed

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    ModelCompanionBaseDAOMethods
  49. def removeByIds(ids: List[ID], wc: com.mongodb.casbah.Imports.WriteConcern = defaultWriteConcern): com.mongodb.casbah.Imports.WriteResult

    ids

    the list of IDs identifying the list of documents to be removed

    wc

    wrote concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    ModelCompanionBaseDAOMethods
  50. def save(t: ObjectType, wc: com.mongodb.casbah.Imports.WriteConcern = defaultWriteConcern): com.mongodb.casbah.Imports.WriteResult

    t

    object to save

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    ModelCompanionBaseDAOMethods
  51. def save(t: ObjectType): com.mongodb.casbah.Imports.WriteResult

    Saves an object to this collection.

    Saves an object to this collection.

    t

    object to save

    returns

    (WriteResult) result of write operation

    Definition Classes
    BaseDAOMethods
  52. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  53. def toCompactJSONArray(t: Traversable[ObjectType]): String

    t

    collection to be serialized

    returns

    collection of model objects serialized to a JSON array and rendered as compact JSON

  54. def toCompactJson(t: ObjectType): String

    t

    object to be serialized

    returns

    object serialized as pretty JSON to a String

    See also

    http://www.assembla.com/spaces/liftweb/wiki/JSON_Support

  55. def toDBObject(t: ObjectType): com.mongodb.casbah.Imports.DBObject

    t

    object to be serialized

    returns

    object serialized as DBObject

    Definition Classes
    ModelCompanionBaseDAOMethods
  56. def toJSONArray(t: Traversable[ObjectType]): JArray

    t

    collection to be serialized

    returns

    collection of model objects serialized as a JSON array of JObject

  57. def toJson(t: ObjectType): JObject

    t

    object to be serialized

    returns

    object serialized to JObject

    See also

    http://www.assembla.com/spaces/liftweb/wiki/JSON_Support

  58. def toMap(t: ObjectType): Map[String, Any]

    t

    model object instance

    returns

    a map populated with the field names and values of the model object

  59. def toObject(dbo: com.mongodb.casbah.Imports.DBObject): ObjectType

    dbo

    DBObject to be deserialized

    returns

    DBObject deserialized to object TODO - bring back view bound... assuming it could possibly be worth the bother.

  60. def toPrettyJSONArray(t: Traversable[ObjectType]): String

    t

    collection to be serialized

    returns

    collection of model objects serialized to a JSON array and rendered as pretty JSON

  61. def toPrettyJson(t: ObjectType): String

    t

    object to be serialized

    returns

    object serialized as pretty JSON to a String

    See also

    http://www.assembla.com/spaces/liftweb/wiki/JSON_Support

  62. def toString(): String

    Definition Classes
    AnyRef → Any
  63. def update(q: com.mongodb.casbah.Imports.DBObject, o: com.mongodb.casbah.Imports.DBObject, upsert: Boolean, multi: Boolean, wc: com.mongodb.casbah.Imports.WriteConcern = defaultWriteConcern): com.mongodb.casbah.Imports.WriteResult

    q

    search query for old object to update

    o

    object with which to update q

    upsert

    if the database should create the element if it does not exist

    multi

    if the update should be applied to all objects matching

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    ModelCompanionBaseDAOMethods
  64. def update(q: DBObject, t: ObjectType, upsert: Boolean, multi: Boolean, wc: WriteConcern): com.mongodb.casbah.Imports.WriteResult

    Performs an update operation.

    Performs an update operation.

    q

    search query for old object to update

    t

    object with which to update q

    upsert

    if the database should create the element if it does not exist

    multi

    if the update should be applied to all objects matching

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    BaseDAOMethods
  65. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def findOneByID(id: ID): Option[ObjectType]

    Find an object by its ID.

    Find an object by its ID.

    id

    identifier

    returns

    (Option[ObjectType]) Some() of the object found, or None if no such object exists

    Definition Classes
    BaseDAOMethods
    Annotations
    @deprecated
    Deprecated

    (Since version 0.0.8) Use findOneById instead

Inherited from Logging

Inherited from BaseDAOMethods[ObjectType, ID]

Inherited from AnyRef

Inherited from Any

Ungrouped