com.mongodb.casbah

MongoDB

class MongoDB extends AnyRef

Wrapper for the Mongo DB object providing scala-friendly functionality.

Source
MongoDB.scala
Since

1.0

See also

com.mongodb.DB

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. MongoDB
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MongoDB (underlying: DB)

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 addOption (option: Int): Unit

    Manipulate Network Options

    Manipulate Network Options

    See also

    com.mongodb.Bytes

    ,

    com.mongodb.Mongo

  7. def addUser (username: String, passwd: String): WriteResult

  8. def apply (collection: String): MongoCollection

    Apply method to proxy getCollection, to allow invocation of dbInstance("collectionName") instead of getCollection

    Apply method to proxy getCollection, to allow invocation of dbInstance("collectionName") instead of getCollection

    collection

    a string for the collection name

    returns

    MongoCollection A wrapped instance of a Mongo DBCollection Class returning generic DBObjects

  9. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  10. def authenticate (username: String, passwd: String): Boolean

    Authenticates connection/db with given name and password

    Authenticates connection/db with given name and password

    username

    name of user for this database

    passwd

    password of user for this database

    returns

    true if authenticated, false otherwise

  11. def checkedWrite (op: (MongoDB) ⇒ WriteResult): Unit

  12. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  13. def collectionExists (collectionName: String): Boolean

    Checks to see if a collection by name %lt;name> exists.

    Checks to see if a collection by name %lt;name> exists.

    collectionName

    The collection to test for existence

    returns

    false if no collection by that name exists, true if a match to an existing collection was found

  14. def collectionNames : Set[String]

    Returns a set of the names of collections in this database.

    Returns a set of the names of collections in this database.

    returns

    the names of collections in this database

  15. def command (cmd: DBObject, options: Int): CommandResult

    Execute a database command directly.

    Execute a database command directly.

    returns

    the result of the command from the database

    See also

    List of Commands

  16. def command (cmd: String): CommandResult

    Execute a database command directly.

    Execute a database command directly.

    returns

    the result of the command from the database

    See also

    List of Commands

  17. def command (cmd: DBObject): CommandResult

    Execute a database command directly.

    Execute a database command directly.

    returns

    the result of the command from the database

    See also

    List of Commands

  18. def createCollection (name: String, o: DBObject): DBCollection

    Creates a collection with a given name and options.

    Creates a collection with a given name and options. If the collection does not exist, a new collection is created. Possible options: <dl> <dt>capped</dt>

    boolean: if the collection is capped
    <dt>size</dt>
    int: collection size
    <dt>max</dt>
    int: max number of documents
    </dl>

    name

    the name of the collection to return

    o

    options

    returns

    the collection

  19. def doEval (code: String, args: AnyRef*): CommandResult

  20. def dropDatabase (): Unit

    Drops this database.

    Drops this database. Removes all data on disk. Use with caution.

  21. def eq (arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  23. def eval (code: String, args: AnyRef*): AnyRef

  24. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  25. def forceError (): Unit

    For testing purposes only - this method forces an error to help test error handling

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

    Attributes
    final
    Definition Classes
    AnyRef
  27. def getCollection (name: String): DBCollection

    Gets a collection with a given name.

    Gets a collection with a given name. If the collection does not exist, a new collection is created.

    name

    (String) the name of the collection to return

    returns

    the collection

  28. def getCollectionFromString (s: String): DBCollection

    Returns a collection matching a given string.

    Returns a collection matching a given string.

    s

    the name of the collection

    returns

    the collection

  29. def getCollectionNames (): Set[String]

    Returns a set of the names of collections in this database.

    Returns a set of the names of collections in this database.

    returns

    the names of collections in this database

  30. def getLastError (w: Int, wTimeout: Int, fsync: Boolean): CommandResult

  31. def getLastError (writeConcern: WriteConcern): CommandResult

  32. def getLastError (): CommandResult

    Gets the the error (if there is one) from the previous operation.

    Gets the the error (if there is one) from the previous operation. The result of this command will look like

    { "err" :  errorMessage  , "ok" : 1.0 }
    

    The value for errorMessage will be null if no error occurred, or a description otherwise.

    Care must be taken to ensure that calls to getLastError go to the same connection as that of the previous operation. See com.mongodb.Mongo.requestStart for more information.

    returns

    DBObject with error and status information

  33. def getName (): String

  34. def getOptions (): Int

    Manipulate Network Options

    Manipulate Network Options

    See also

    com.mognodb.Bytes

    ,

    com.mongodb.Mongo

  35. def getSisterDB (name: String): MongoDB

  36. def getStats (): CommandResult

  37. def getWriteConcern (): WriteConcern

    get the write concern for this database, which is used for writes to any collection in this database.

    get the write concern for this database, which is used for writes to any collection in this database. See the documentation for WriteConcern for more info.

    See also

    http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/

    ,

    WriteConcern

  38. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  39. def isAuthenticated : Boolean

    Returns true if this DB is authenticated

    Returns true if this DB is authenticated

    returns

    true if authenticated, false otherwise

  40. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  41. def lastError (w: Int, wTimeout: Int, fsync: Boolean): CommandResult

  42. def lastError (writeConcern: WriteConcern): CommandResult

  43. def lastError (): CommandResult

  44. def mapReduce (cmd: MapReduceCommand): MapReduceResult

    The Java Driver is a bit outdated and is missing the finalize option.

    The Java Driver is a bit outdated and is missing the finalize option. Additionally, it returns ZERO information about the actual results of the mapreduce, just a cursor to the result collection. This is less than ideal. So I've wrapped it in something more useful.

    returns

    MapReduceResult a wrapped result object. This contains the returns success, counts etc, but implements iterator and can be iterated directly

  45. def name : String

  46. def ne (arg0: AnyRef): Boolean

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

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

    Attributes
    final
    Definition Classes
    AnyRef
  49. def options : Int

    Manipulate Network Options

    Manipulate Network Options

    See also

    com.mognodb.Bytes

    ,

    com.mongodb.Mongo

  50. def readOnly_= (b: Boolean): Unit

    Makes this database read-only

    Makes this database read-only

    b

    if the database should be read-only

  51. def request (writeConcern: WriteConcern)(op: (MongoDB) ⇒ WriteResult): Unit

    write concern aware write op block.

    write concern aware write op block.

    Checks getLastError after the last write. If you run multiple ops you'll only get the final error.

    Your op function gets a copy of this MongoDB instance.

    This is for write ops only - you cannot return data from it.

    Your function must return WriteResult, which is the return type of any mongo write operation like insert/save/update/remove

  52. def request (w: Int, wTimeout: Int = 0, fsync: Boolean = false)(op: (MongoDB) ⇒ WriteResult): Unit

    write concern aware write op block.

    write concern aware write op block.

    Checks getLastError after the last write. If you run multiple ops you'll only get the final error.

    Your op function gets a copy of this MongoDB instance.

    This is for write ops only - you cannot return data from it.

    Your function must return WriteResult, which is the return type of any mongo write operation like insert/save/update/remove

  53. def request (op: (MongoDB) ⇒ WriteResult): Unit

    write concern aware write op block.

    write concern aware write op block.

    Checks getLastError after the last write. If you run multiple ops you'll only get the final error.

    Your op function gets a copy of this MongoDB instance.

    This is for write ops only - you cannot return data from it.

    Your function must return WriteResult, which is the return type of any mongo write operation like insert/save/update/remove

    If you have set a connection or DB level WriteConcern, it will be inherited.

  54. def requestDone (): Unit

  55. def requestEnsureConnection (): Unit

  56. def requestStart (): Unit

  57. def resetOptions (): Unit

    Manipulate Network Options

    Manipulate Network Options

    See also

    com.mongodb.Bytes

    ,

    com.mongodb.Mongo

  58. def setReadOnly (b: Boolean): Unit

    Makes this database read-only

    Makes this database read-only

    b

    if the database should be read-only

  59. def setWriteConcern (concern: WriteConcern): Unit

    Set the write concern for this database.

    Set the write concern for this database. Will be used for writes to any collection in this database. See the documentation for WriteConcern for more info.

    concern

    (WriteConcern) The write concern to use

    See also

    http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/

    ,

    WriteConcern

  60. def slaveOk (): Unit

    Sets queries to be OK to run on slave nodes.

  61. def stats : CommandResult

  62. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  63. def toString (): String

    Definition Classes
    MongoDB → AnyRef → Any
  64. val underlying : DB

  65. def wait (): Unit

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

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  68. def writeConcern : WriteConcern

    get the write concern for this database, which is used for writes to any collection in this database.

    get the write concern for this database, which is used for writes to any collection in this database. See the documentation for WriteConcern for more info.

    See also

    http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/

    ,

    WriteConcern

  69. def writeConcern_= (concern: WriteConcern): Unit

    Set the write concern for this database.

    Set the write concern for this database. Will be used for writes to any collection in this database. See the documentation for WriteConcern for more info.

    concern

    (WriteConcern) The write concern to use

    See also

    http://www.thebuzzmedia.com/mongodb-single-server-data-durability-guide/

    ,

    WriteConcern

  70. def getPreviousError (): CommandResult

    Returns the last error that occurred since start of database or a call to resetError()

    Returns the last error that occurred since start of database or a call to resetError()

    The return object will look like

    { err : errorMessage, nPrev : countOpsBack, ok : 1 }
    

    The value for errormMessage will be null of no error has ocurred, or the message. The value of countOpsBack will be the number of operations since the error occurred.

    Care must be taken to ensure that calls to getPreviousError go to the same connection as that of the previous operation. See com.mongodb.Mongo.requestStart for more information.

    returns

    DBObject with error and status information

    Deprecated

    The getPreviousError() and resetError() commands are deprecated and may be removed in future versions of MongoDB

  71. def resetError (): Unit

    Resets the error memory for this database.

    Resets the error memory for this database. Used to clear all errors such that getPreviousError() will return no error.

    Deprecated

    The getPreviousError() and resetError() commands are deprecated and may be removed in future versions of MongoDB

Inherited from AnyRef

Inherited from Any