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

    Manipulate Network Options

    Manipulate Network Options

    See also

    com.mongodb.Bytes

    ,

    com.mongodb.Mongo

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

  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  10. 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

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

  12. def command(cmd: DBObject, readPreference: ReadPreference): 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

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

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

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

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

  17. def dropDatabase(): Unit

    Drops this database.

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

  18. final def eq(arg0: AnyRef): Boolean

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

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

  21. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  22. final def getClass(): java.lang.Class[_]

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

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

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

  26. def getName: String

  27. def getOptions: Int

    Manipulate Network Options

    Manipulate Network Options

    See also

    com.mognodb.Bytes

    ,

    com.mongodb.Mongo

  28. def getReadPreference: ReadPreference

    Gets the read preference for this database.

    Gets the read preference for this database. Will be used as default for reads from any collection in this database. See the documentation for com.mongodb.ReadPreference for more information.

  29. def getSisterDB(name: String): MongoDB

  30. def getStats(): CommandResult

  31. 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 com.mongodb.WriteConcern for more info.

    See also

    WriteConcern

  32. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  33. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  34. 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.

    cmd

    An instance of MapReduceCommand representing the required MapReduce

    returns

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

  35. def name: String

  36. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  39. def options: Int

    Manipulate Network Options

    Manipulate Network Options

    See also

    com.mognodb.Bytes

    ,

    com.mongodb.Mongo

  40. def readPreference: ReadPreference

    Gets the read preference for this database.

    Gets the read preference for this database. Will be used as default for reads from any collection in this database. See the documentation for com.mongodb.ReadPreference for more information.

  41. def readPreference_=(pref: ReadPreference): Unit

  42. def resetOptions(): Unit

    Manipulate Network Options

    Manipulate Network Options

    See also

    com.mongodb.Bytes

    ,

    com.mongodb.Mongo

  43. def setReadPreference(pref: ReadPreference): Unit

    Sets the read preference for this database.

    Sets the read preference for this database. Will be used as default for reads from any collection in this database. See the documentation for com.mongodb.ReadPreference for more information.

    pref

    Read Preference to use

  44. 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 com.mongodb.WriteConcern for more info.

    concern

    (WriteConcern) The write concern to use

    See also

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

    ,

    WriteConcern

  45. def stats(): CommandResult

  46. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  47. def toString(): String

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

  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()
  52. 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 com.mongodb.WriteConcern for more info.

    See also

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

    ,

    WriteConcern

  53. 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 com.mongodb.WriteConcern for more info.

    concern

    (WriteConcern) The write concern to use

    See also

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

    ,

    WriteConcern

Deprecated Value Members

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

    Adds or updates a user for this database

    Adds or updates a user for this database

    username

    the user name

    passwd

    the password

    returns

    the result of executing this operation

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

    Exceptions thrown
    MongoException
  2. 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

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.7) Please use MongoClient to create a client, which will authenticate all connections to server.

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

    Checked write block

    Checked write block

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

    Exceptions thrown
    MongoException

    if error

  4. def command(cmd: DBObject, options: Int, pref: ReadPreference): CommandResult

    Execute a database command directly.

    Execute a database command directly.

    returns

    the result of the command from the database

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

    See also

    List of Commands

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

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

    See also

    List of Commands

  6. def forceError(): Unit

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

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

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

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

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

  8. def getLastError(writeConcern: WriteConcern): CommandResult

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

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

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

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

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.7) This will be removed in a future release

  11. def isAuthenticated: Boolean

    Returns true if this DB is authenticated

    Returns true if this DB is authenticated

    returns

    true if authenticated, false otherwise

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.7) Use MongoClient to create an authenticated connection.

  12. def lastError(w: Int, wTimeout: Int, fsync: Boolean): CommandResult

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

  13. def lastError(writeConcern: WriteConcern): CommandResult

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

  14. def lastError(): CommandResult

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

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

    Makes this database read-only

    Makes this database read-only

    b

    if the database should be read-only

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.7) Avoid making database read-only via this method. Use a read-only user with MongoClient instead.

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

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

    Exceptions thrown
    MongoException

    if error

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

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

    Exceptions thrown
    MongoException

    if error

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

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

    Exceptions thrown
    MongoException

    if error

  19. def requestDone(): Unit

    Ends the current 'consistent request'.

    Ends the current 'consistent request'.

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

  20. def requestEnsureConnection(): Unit

    Ensure that a connection is assigned to the current "consistent request" (from primary pool, if connected to a replica set).

    Ensure that a connection is assigned to the current "consistent request" (from primary pool, if connected to a replica set).

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

  21. def requestStart(): Unit

    Starts a new 'consistent request'.

    Starts a new 'consistent request'.

    Following this call and until requestDone() is called, all db operations will use the same underlying connection.

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.8) This will be removed in a future release

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

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.7) This will be removed in a future release

  23. def setReadOnly(b: Boolean): Unit

    Makes this database read-only

    Makes this database read-only

    b

    if the database should be read-only

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.7) Avoid making database read-only via this method. Use a read-only user with MongoClient instead.

  24. def slaveOk(): Unit

    Sets queries to be OK to run on slave nodes.

    Sets queries to be OK to run on slave nodes.

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 2.3.0) Replaced with ReadPreference.SECONDARY.

Inherited from AnyRef

Inherited from Any