com.novus.salat.dao

ModelCompanion

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

Play framework style model companion

  package model

 import com.novus.salat.annotations._
 import com.mongodb.casbah.Imports._
 import com.novus.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. Hide All
  2. Show all
  1. ModelCompanion
  2. Logging
  3. BaseDAOMethods
  4. AnyRef
  5. Any
Visibility
  1. Public
  2. All

Abstract Value Members

  1. def dao : DAO[ObjectType, ID]

    Attributes
    abstract

Concrete 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 asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  7. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. def count (q: DBObject, fieldsThatMustExist: List[String] = Nil, fieldsThatMustNotExist: List[String] = Nil): 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

    returns

    count of documents matching the search criteria

    Definition Classes
    ModelCompanionBaseDAOMethods
  9. 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
  10. def eq (arg0: AnyRef): Boolean

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

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

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  13. def find [A, B] (ref: A, keys: B)(implicit arg0: (A) ⇒ DBObject, arg1: (B) ⇒ 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

    returns

    a typed cursor to iterate over results

    Definition Classes
    ModelCompanionBaseDAOMethods
  14. 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
  15. def findAll (): SalatMongoCursor[ObjectType]

    returns

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

  16. def findOne [A] (t: A)(implicit arg0: (A) ⇒ DBObject): Option[ObjectType]

    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
    ModelCompanionBaseDAOMethods
  17. 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
  18. def fromJSON (s: String): ObjectType

    s

    string representing a valid JSON object

    returns

    JSON deserialized to a model object

  19. def fromJSON (j: JObject): ObjectType

    j

    JObject to be deserialized

    returns

    JObject deserialized to a model object

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

    s

    string representing a JSON array of valid JObjects

    returns

    deserialized list of model objects

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

    j

    JSON array of valid JObjects

    returns

    deserialized list of model objects

  22. 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

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

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

    Definition Classes
    AnyRef → Any
  25. def ids [A] (query: A)(implicit arg0: (A) ⇒ DBObject): List[ID]

    A

    type view bound to DBObject

    query

    query

    returns

    list of IDs

    Definition Classes
    ModelCompanionBaseDAOMethods
  26. def insert (t: ObjectType, wc: WriteConcern): Option[ID]

    t

    instance of ObjectType

    wc

    write concern

    returns

    if insert succeeds, ID of inserted object

    Definition Classes
    ModelCompanionBaseDAOMethods
  27. def insert (docs: Traversable[ObjectType], wc: 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
  28. 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
  29. 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
  30. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  31. lazy val log : Logger

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

    Attributes
    final
    Definition Classes
    AnyRef
  33. def notify (): Unit

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

    Attributes
    final
    Definition Classes
    AnyRef
  35. def primitiveProjection [P] (query: 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 Context

    returns

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

    Definition Classes
    ModelCompanionBaseDAOMethods
  36. def primitiveProjections [P] (query: 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 Context

    returns

    (List[P]) of the objects found

    Definition Classes
    ModelCompanionBaseDAOMethods
  37. def projection [P <: CaseClass] (query: 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 Context

    returns

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

    Definition Classes
    ModelCompanionBaseDAOMethods
  38. def projections [P <: CaseClass] (query: 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 Context

    returns

    (List[P]) of the objects found

    Definition Classes
    ModelCompanionBaseDAOMethods
  39. def remove [A] (q: A, wc: WriteConcern)(implicit arg0: (A) ⇒ DBObject): WriteResult

    A
    q

    the object that documents to be removed must match

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    ModelCompanionBaseDAOMethods
  40. def remove (t: ObjectType, wc: WriteConcern = defaultWriteConcern): WriteResult

    t

    object to remove from the collection

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    ModelCompanionBaseDAOMethods
  41. def remove [A] (q: A)(implicit arg0: (A) ⇒ DBObject): 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
  42. def remove (t: ObjectType): 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
  43. def removeById (id: ID, wc: WriteConcern = defaultWriteConcern): WriteResult

    id

    the ID of the document to be removed

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    ModelCompanionBaseDAOMethods
  44. def removeByIds (ids: List[ID], wc: WriteConcern = defaultWriteConcern): 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
  45. def save (t: ObjectType, wc: WriteConcern = defaultWriteConcern): WriteResult

    t

    object to save

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    ModelCompanionBaseDAOMethods
  46. def save (t: ObjectType): 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
  47. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  48. 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

  49. 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

  50. def toDBObject (t: ObjectType): DBObject

    t

    object to be serialized

    returns

    object serialized as DBObject

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

    t

    collection to be serialized

    returns

    collection of model objects serialized as a JSON array of JObject

  52. 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

  53. 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

  54. def toObject (dbo: 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.

  55. 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

  56. 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

  57. def toString (): String

    Definition Classes
    AnyRef → Any
  58. def update (q: DBObject, o: DBObject, upsert: Boolean, multi: Boolean, wc: WriteConcern = defaultWriteConcern): 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
  59. def update (q: DBObject, t: ObjectType, upsert: Boolean, multi: Boolean, wc: WriteConcern): 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
  60. def wait (): Unit

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

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

    Attributes
    final
    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

    Use findOneById instead

Inherited from Logging

Inherited from BaseDAOMethods[ObjectType, ID]

Inherited from AnyRef

Inherited from Any