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. SalatDAO
  2. Logging
  3. DAO
  4. BaseDAOMethods
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new SalatDAO(collection: mongodb.casbah.Imports.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 com.novus.salat.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 com.novus.salat.Grater from the implicit com.novus.salat.Context and ObjectType manifest

    Supplies the com.novus.salat.Grater from the implicit com.novus.salat.Context and ObjectType manifest

    returns

    com.novus.salat.Grater to serialize and deserialize ObjectType

    Definition Classes
    SalatDAODAO
  7. val appendTypeHintToQueries: Boolean

    If you are mixing and matching abstract and concrete DAOs, turn this on in the concrete DAOs to ensure that querying on a mixed collection will only yield results in the child collection.

  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  10. val collection: mongodb.casbah.Imports.MongoCollection

    MongoDB collection

    MongoDB collection

    Definition Classes
    SalatDAODAO
  11. 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
  12. def decorateDBO(toPersist: ObjectType): mongodb.casbah.Imports.DBObject

    A central place to modify DBOs before inserting, saving, or updating.

    A central place to modify DBOs before inserting, saving, or updating.

    toPersist

    object to be serialized

    returns

    decorated DBO for persisting

  13. def decorateQuery(query: DBObject): DBObject

    A central place to modify find, count and update queries before executing them.

    A central place to modify find, count and update queries before executing them.

    query

    query to decorate

    returns

    decorated query for execution

  14. 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
  15. 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
  16. final def eq(arg0: AnyRef): Boolean

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

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

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  19. 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
  20. 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
  21. 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
  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
    SalatDAOBaseDAOMethods
  23. val forceTypeHints: Boolean

    Force type hints when objects are persisted.

    Force type hints when objects are persisted. Used to support a DAO typed to an abstract superclass or trait. Should be overriden and forced to true when you want to select

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

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

    Definition Classes
    AnyRef → Any
  26. 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
  27. 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
  28. 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
  29. 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
  30. 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
  31. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  32. var log: Logger

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

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

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

    Definition Classes
    AnyRef
  36. 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 com.novus.salat.Context

    returns

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

    Definition Classes
    SalatDAOBaseDAOMethods
  37. 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 com.novus.salat.Context

    returns

    (List[P]) of the objects found

    Definition Classes
    SalatDAOBaseDAOMethods
  38. 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 com.novus.salat.Context

    returns

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

    Definition Classes
    SalatDAOBaseDAOMethods
  39. 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 com.novus.salat.Context

    returns

    (List[P]) of the objects found

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

    q

    the object that documents to be removed must match

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    SalatDAOBaseDAOMethods
  41. def remove(t: ObjectType, wc: WriteConcern): WriteResult

    t

    object to remove from the collection

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    SalatDAOBaseDAOMethods
  42. def remove[A](q: A)(implicit arg0: (A) ⇒ DBObject): 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
  43. def remove(t: ObjectType): 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
  44. 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
    SalatDAOBaseDAOMethods
  45. def removeByIds(ids: List[ID], wc: WriteConcern): 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
    SalatDAOBaseDAOMethods
  46. def save(t: ObjectType, wc: WriteConcern): WriteResult

    t

    object to save

    wc

    write concern

    returns

    (WriteResult) result of write operation

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

    Definition Classes
    AnyRef
  49. def toDBObject(o: ObjectType): mongodb.casbah.Imports.DBObject

    o

    object to transform

    returns

    object serialized as DBObject

    Definition Classes
    DAOBaseDAOMethods
  50. def toString(): String

    Definition Classes
    AnyRef → Any
  51. def update(q: DBObject, o: DBObject, upsert: Boolean = false, multi: Boolean = false, wc: WriteConcern = defaultWriteConcern): 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
    SalatDAOBaseDAOMethods
  52. def update(q: DBObject, t: ObjectType, upsert: Boolean, multi: Boolean, wc: WriteConcern): 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
  53. final def wait(): Unit

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

    Definition Classes
    AnyRef
    Annotations
    @throws()
  55. 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

Ungrouped