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.

    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.

    Given parent class Foo and child class Bar:

    case class Foo(_id: ObjectId, //  etc )
    case class Bar(_id: ObjectId,
                   parentId: ObjectId, // this refers back to a parent in Foo collection
                   //  etc )
    
    object FooDAO extends SalatDAO[Foo, ObjectId](collection = MongoConnection()("db")("fooCollection")) {
    
    // and here is a child DAO you can use within FooDAO to work with children of type Bar whose parentId field matches
    // the supplied parent id of an instance of Foo
     val bar = new ChildCollection[Bar, ObjectId](collection = MongoConnection()("db")("barCollection"),
     parentIdField = "parentId") { }
    
    }
    ChildType

    type of child object

    ChildID

    type of child _id field

Value Members

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

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Definition Classes
    AnyRef → Any
  4. 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
  5. 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.

  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

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

    MongoDB collection

    MongoDB collection

    Definition Classes
    SalatDAODAO
  9. def count(q: DBObject = MongoDBObject.empty, fieldsThatMustExist: List[String] = Nil, fieldsThatMustNotExist: List[String] = Nil, rp: mongodb.casbah.Imports.ReadPreference = defaultReadPreference): Long

    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
    SalatDAOBaseDAOMethods
  10. 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

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

  12. def defaultReadPreference: mongodb.casbah.Imports.ReadPreference

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

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

    returns

    default read preference to use for find and findOne

    Definition Classes
    DAOBaseDAOMethods
  13. def defaultWriteConcern: mongodb.casbah.Imports.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
  14. 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.

    returns

    DAO description for logging

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

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

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

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. def find[A, B](ref: A, keys: B, rp: mongodb.casbah.Imports.ReadPreference)(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

    rp

    sets the desired ReadPreference on the cursor

    returns

    a typed cursor to iterate over results

    Definition Classes
    SalatDAOBaseDAOMethods
  19. 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
  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, rp: mongodb.casbah.Imports.ReadPreference)(implicit arg0: (A) ⇒ DBObject): Option[ObjectType]

    A

    type view bound to DBObject

    t

    object for which to search

    rp

    the ReadPreference used for this find

    returns

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

    Definition Classes
    SalatDAOBaseDAOMethods
  22. 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
  23. 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
  24. 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

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

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

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

    Definition Classes
    Any
  33. var log: Logger

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

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

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

    Definition Classes
    AnyRef
  37. 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
  38. 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
  39. 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
  40. 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
  41. def remove[A](q: A, wc: WriteConcern)(implicit arg0: (A) ⇒ DBObject): mongodb.casbah.TypeImports.WriteResult

    q

    the object that documents to be removed must match

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    SalatDAOBaseDAOMethods
  42. def remove(t: ObjectType, wc: WriteConcern): mongodb.casbah.TypeImports.WriteResult

    t

    object to remove from the collection

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    SalatDAOBaseDAOMethods
  43. 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
  44. 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
  45. def removeById(id: ID, wc: WriteConcern = defaultWriteConcern): mongodb.casbah.TypeImports.WriteResult

    id

    the ID of the document to be removed

    wc

    write concern

    returns

    (WriteResult) result of write operation

    Definition Classes
    SalatDAOBaseDAOMethods
  46. def removeByIds(ids: List[ID], wc: WriteConcern): mongodb.casbah.TypeImports.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
  47. def save(t: ObjectType, wc: WriteConcern): mongodb.casbah.TypeImports.WriteResult

    t

    object to save

    wc

    write concern

    returns

    (WriteResult) result of write operation

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

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

    o

    object to transform

    returns

    object serialized as DBObject

    Definition Classes
    DAOBaseDAOMethods
  51. def toString(): String

    Definition Classes
    AnyRef → Any
  52. 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
  53. 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
  54. final def wait(): Unit

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

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