com.novus.salat.dao

SalatDAO

abstract class SalatDAO[ObjectType <: AnyRef, ID] extends DAO[ObjectType, ID] with Logging

Sample DAO implementation.

ObjectType

class to be persisted

ID

_id type

Self Type
SalatDAO[ObjectType, ID]
Linear Supertypes
Logging, DAO[ObjectType, ID], BaseDAOMethods[ObjectType, ID], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. SalatDAO
  2. Logging
  3. DAO
  4. BaseDAOMethods
  5. AnyRef
  6. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new SalatDAO(collection: MongoCollection)(implicit mot: Manifest[ObjectType], mid: Manifest[ID], ctx: Context)

    collection

    MongoDB collection

    mot

    implicit manifest for ObjectType

    mid

    implicit manifest for ID

    ctx

    implicit Context

Type Members

  1. abstract class ChildCollection[ChildType <: AnyRef, ChildID] extends SalatDAO[ChildType, ChildID]

    Inner abstract class to facilitate working with child collections using a typed parent id - no cascading support will be offered, but you can override saves and deletes in the parent DAO to manually cascade children as you like.

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. val _grater: Grater[ObjectType]

    Supplies the Grater from the implicit Context and ObjectType manifest

    Supplies the Grater from the implicit Context and ObjectType manifest

    returns

    Grater to serialize and deserialize ObjectType

    Definition Classes
    SalatDAODAO
  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  9. val collection: MongoCollection

    MongoDB collection

    MongoDB collection

    Definition Classes
    SalatDAODAO
  10. def count(q: DBObject = MongoDBObject.empty, fieldsThatMustExist: List[String] = Nil, fieldsThatMustNotExist: List[String] = Nil): Long

    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
    SalatDAOBaseDAOMethods
  11. 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
    DAOBaseDAOMethods
  12. lazy val description: String

    Default description is the case class simple name and the collection.

    Default description is the case class simple name and the collection.

    Definition Classes
    SalatDAODAO
  13. final def eq(arg0: AnyRef): Boolean

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

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

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  16. 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
    SalatDAOBaseDAOMethods
  17. 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
  18. 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
    SalatDAOBaseDAOMethods
  19. 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
    SalatDAOBaseDAOMethods
  20. final def getClass(): java.lang.Class[_]

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

    Definition Classes
    AnyRef → Any
  22. 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
    SalatDAOBaseDAOMethods
  23. def insert(docs: Traversable[ObjectType], wc: WriteConcern = defaultWriteConcern): 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
    SalatDAOBaseDAOMethods
  24. 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
    SalatDAOBaseDAOMethods
  25. 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
  26. 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
  27. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  28. var log: Logger

    Attributes
    protected[casbah]
    Definition Classes
    Logging
  29. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  32. 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
    SalatDAOBaseDAOMethods
  33. 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
    SalatDAOBaseDAOMethods
  34. 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
    SalatDAOBaseDAOMethods
  35. 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
    SalatDAOBaseDAOMethods
  36. def remove[A](q: A, wc: WriteConcern)(implicit arg0: (A) ⇒ DBObject): Unit

    q

    the object that documents to be removed must match

    wc

    write concern

    Definition Classes
    SalatDAOBaseDAOMethods
  37. def remove(t: ObjectType, wc: WriteConcern): Unit

    t

    object to remove from the collection

    wc

    write concern

    Definition Classes
    SalatDAOBaseDAOMethods
  38. def remove[A](q: A)(implicit arg0: (A) ⇒ DBObject): Unit

    Removes objects from the database collection.

    Removes objects from the database collection.

    q

    the object that documents to be removed must match

    Definition Classes
    BaseDAOMethods
  39. def remove(t: ObjectType): Unit

    Remove a matching object from the collection

    Remove a matching object from the collection

    t

    object to remove from the collection

    Definition Classes
    BaseDAOMethods
  40. def removeById(id: ID, wc: WriteConcern = defaultWriteConcern): Unit

    id

    the ID of the document to be removed

    wc

    write concern

    Definition Classes
    SalatDAOBaseDAOMethods
  41. def removeByIds(ids: List[ID], wc: WriteConcern): Unit

    ids

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

    wc

    wrote concern

    Definition Classes
    SalatDAOBaseDAOMethods
  42. def save(t: ObjectType, wc: WriteConcern): Unit

    t

    object to save

    wc

    write concern

    Definition Classes
    SalatDAOBaseDAOMethods
  43. def save(t: ObjectType): Unit

    Saves an object to this collection.

    Saves an object to this collection.

    t

    object to save

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

    Definition Classes
    AnyRef
  45. def toDBObject(o: ObjectType): DBObject

    o

    object to transform

    returns

    object serialized as DBObject

    Definition Classes
    DAOBaseDAOMethods
  46. def toString(): String

    Definition Classes
    AnyRef → Any
  47. def update(q: DBObject, o: DBObject, upsert: Boolean = false, multi: Boolean = false, wc: WriteConcern = defaultWriteConcern): Unit

    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

    Definition Classes
    SalatDAOBaseDAOMethods
  48. def update(q: DBObject, t: ObjectType, upsert: Boolean, multi: Boolean, wc: WriteConcern): Unit

    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

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()
  51. 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 DAO[ObjectType, ID]

Inherited from BaseDAOMethods[ObjectType, ID]

Inherited from AnyRef

Inherited from Any