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. MongoDB
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
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 addUser(username: String, passwd: String): Imports.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. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. def checkedWrite(op: (MongoDB) ⇒ Imports.WriteResult): Unit

  11. def clone(): AnyRef

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

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

  14. def command(cmd: Imports.DBObject, options: Int, pref: Imports.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

  15. def command(cmd: Imports.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: Imports.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: Imports.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. final def eq(arg0: AnyRef): Boolean

    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[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  25. def forceError(): Unit

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

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

    Definition Classes
    AnyRef → Any
  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: Imports.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 getReadPreference: Imports.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.

  36. def getSisterDB(name: String): MongoDB

  37. def getStats(): CommandResult

  38. def getWriteConcern: Imports.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

  39. def hashCode(): Int

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

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

  42. def lastError(writeConcern: Imports.WriteConcern): CommandResult

  43. def lastError(): CommandResult

  44. def mapReduce(cmd: map_reduce.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

  45. def name: String

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

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

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

    Definition Classes
    AnyRef
  49. def options: Int

    Manipulate Network Options

    Manipulate Network Options

    See also

    com.mognodb.Bytes

    com.mongodb.Mongo

  50. def readPreference: Imports.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.

  51. def readPreference_=(pref: Imports.ReadPreference): Unit

  52. def request(writeConcern: Imports.WriteConcern)(op: (MongoDB) ⇒ Imports.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/upd§ate/remove

    Exceptions thrown
    MongoException

    if error

  53. def request(w: Int, wTimeout: Int = 0, fsync: Boolean = false)(op: (MongoDB) ⇒ Imports.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

    Exceptions thrown
    MongoException

    if error

  54. def request(op: (MongoDB) ⇒ Imports.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.

    Exceptions thrown
    MongoException

    if error

  55. def requestDone(): Unit

  56. def requestEnsureConnection(): Unit

  57. def requestStart(): Unit

  58. def resetOptions(): Unit

    Manipulate Network Options

    Manipulate Network Options

    See also

    com.mongodb.Bytes

    com.mongodb.Mongo

  59. def setReadPreference(pref: Imports.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

  60. def setWriteConcern(concern: Imports.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

  61. def stats(): CommandResult

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

    Definition Classes
    AnyRef
  63. def toString(): String

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

  65. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  68. def writeConcern: Imports.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

  69. def writeConcern_=(concern: Imports.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 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
    Deprecated

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

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

    (Since version 2.7) may be removed in future versions of MongoDB

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

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

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

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

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

    (Since version 2.7) may be removed in future versions of MongoDB

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

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

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

    (Since version 2.3.0) Replaced with ReadPreference.SECONDARY.

Inherited from AnyRef

Inherited from Any

Ungrouped