class Db extends Object
Mongo Database
- Annotations
- @RawJSType() @native() @JSImport( "mongodb" , "Db" )
- See also
https://mongodb.github.io/node-mongodb-native/api-articles/nodekoarticle1.html
- Alphabetic
- By Inheritance
- Db
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addUser(username: String, password: String, callback: MongoCallback1[CommandResult]): Unit
Add a user to the database.
Add a user to the database.
- username
the username.
- password
the password.
- callback
the results callback
-
def
addUser(username: String, password: String, options: RawOptions, callback: MongoCallback1[CommandResult]): Unit
Add a user to the database.
Add a user to the database.
- username
the username.
- password
the password.
- options
the optional settings.
- callback
the results callback
-
def
addUser(username: String, password: String, options: RawOptions = js.native): Promise[CommandResult]
Add a user to the database.
Add a user to the database.
- username
the username.
- password
the password.
- options
the optional settings.
- returns
the promise of the result
-
def
admin(): Admin
Returns the Admin db instance
Returns the Admin db instance
- returns
the Admin db instance
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
authenticate(username: String, password: String, callback: MongoCallback1[CommandResult]): Unit
Authenticate a user against the server.
Authenticate a user against the server.
- username
the username.
- password
the password.
- callback
the results callback
-
def
authenticate(username: String, password: String, options: RawOptions, callback: MongoCallback1[CommandResult]): Unit
Authenticate a user against the server.
Authenticate a user against the server.
- username
the username.
- password
the password.
- options
the optional settings.
- callback
the results callback
-
def
authenticate(username: String, password: String, options: RawOptions = js.native): Promise[CommandResult]
Authenticate a user against the server.
Authenticate a user against the server.
- username
the username.
- password
the password.
- options
the optional settings.
- returns
the promise of the result
- var bufferMaxEntries: Int
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
close(callback: MongoCallback1[Null]): Unit
Close the db and its underlying connections
Close the db and its underlying connections
- callback
the results callback
-
def
close(force: Boolean, callback: MongoCallback1[Null]): Unit
Close the db and its underlying connections
Close the db and its underlying connections
- force
Force close, emitting no events
- callback
the results callback
-
def
close(force: Boolean = js.native): Promise[Null]
Close the db and its underlying connections
Close the db and its underlying connections
- force
Force close, emitting no events
- returns
the promise of the result
-
def
collection(name: String, options: |[CollectionOptions, RawOptions], callback: MongoCallback1[Collection]): Unit
Fetch a specific collection (containing the actual collection information).
Fetch a specific collection (containing the actual collection information). If the application does not use strict mode you can can use it without a callback in the following way:
var collection = db.collection('mycollection');
- name
the collection name we wish to access.
- options
the optional settings.
- callback
the collection result callback
-
def
collection(name: String, callback: MongoCallback1[Collection]): Unit
Fetch a specific collection (containing the actual collection information).
Fetch a specific collection (containing the actual collection information). If the application does not use strict mode you can can use it without a callback in the following way:
var collection = db.collection('mycollection');
- name
the collection name we wish to access.
- callback
the collection result callback
-
def
collection(name: String, options: |[CollectionOptions, RawOptions] = js.native): Collection
Fetch a specific collection (containing the actual collection information).
Fetch a specific collection (containing the actual collection information). If the application does not use strict mode you can can use it without a callback in the following way:
var collection = db.collection('mycollection');
- name
the collection name we wish to access.
- returns
the collection
-
def
collections(callback: MongoCallback1[Array[Collection]]): Unit
Fetch all collections for the current db.
Fetch all collections for the current db.
- callback
the collections result callback
-
def
collections(): Promise[Array[Collection]]
Fetch all collections for the current db.
Fetch all collections for the current db.
- returns
the promise of an array of collections
-
def
command(command: Any, callback: MongoCallback1[CommandResult]): Unit
Execute a command
Execute a command
- command
the command hash
- callback
the results callback
-
def
command(command: Any, options: RawOptions, callback: MongoCallback1[CommandResult]): Unit
Execute a command
Execute a command
- command
the command hash
- options
the optional settings.
- callback
the results callback
-
def
command(command: Any, options: RawOptions = js.native): Promise[CommandResult]
Execute a command
Execute a command
- command
the command hash
- options
the optional settings.
- returns
the promise of the result
-
def
createCollection(name: String, callback: MongoCallback1[Collection]): Unit
Create a new collection on a server with the specified options.
Create a new collection on a server with the specified options. Use this to create capped collections. More information about command options available at https://docs.mongodb.com/manual/reference/command/create/
- name
the collection name we wish to access.
- callback
the results callback
-
def
createCollection(name: String, options: |[CollectionOptions, RawOptions], callback: MongoCallback1[Collection]): Unit
Create a new collection on a server with the specified options.
Create a new collection on a server with the specified options. Use this to create capped collections. More information about command options available at https://docs.mongodb.com/manual/reference/command/create/
- name
the collection name we wish to access.
- options
the optional settings
- callback
the results callback
-
def
createCollection(name: String, options: |[CollectionOptions, RawOptions] = js.native): Promise[Collection]
Create a new collection on a server with the specified options.
Create a new collection on a server with the specified options. Use this to create capped collections. More information about command options available at https://docs.mongodb.com/manual/reference/command/create/
- name
the collection name we wish to access.
- options
the optional settings
- returns
a promise of the result
-
def
createIndex(name: String, fieldOrSpec: |[String, Any], callback: MongoCallback1[CommandResult]): Unit
Creates an index on the db and collection collection.
Creates an index on the db and collection collection.
- name
the name of the collection to create the index on.
- fieldOrSpec
defines the index.
- callback
the results callback
-
def
createIndex(name: String, fieldOrSpec: |[String, Any], options: |[IndexOptions, RawOptions], callback: MongoCallback1[CommandResult]): Unit
Creates an index on the db and collection collection.
Creates an index on the db and collection collection.
- name
the name of the collection to create the index on.
- fieldOrSpec
defines the index.
- options
the optional settings.
- callback
the results callback
-
def
createIndex(name: String, fieldOrSpec: |[String, Any], options: |[IndexOptions, RawOptions] = js.native): Promise[CommandResult]
Creates an index on the db and collection collection.
Creates an index on the db and collection collection.
- name
the name of the collection to create the index on.
- fieldOrSpec
defines the index.
- options
the optional settings.
- returns
the promise of the result
- val databaseName: String
-
def
db(databaseName: String, options: DbSharingOptions = js.native): Db
Create a new Db instance sharing the current socket connections.
Create a new Db instance sharing the current socket connections. Be aware that the new db instances are related in a parent-child relationship to the original instance so that events are correctly emitted on child db instances. Child db instances are cached so performing db('db1') twice will return the same instance. You can control these behaviors with the options noListener and returnNonCachedInstance.
- databaseName
the name of the database we want to use.
- options
the optional settings.
-
def
dropCollection(name: String, callback: MongoCallback1[CommandResult]): Unit
Drop a collection from the database, removing it permanently.
Drop a collection from the database, removing it permanently. New accesses will create a new collection.
- name
the name of collection to drop
- callback
the results callback
-
def
dropCollection(name: String): Promise[CommandResult]
Drop a collection from the database, removing it permanently.
Drop a collection from the database, removing it permanently. New accesses will create a new collection.
- name
the name of collection to drop
- returns
the promise of the result
-
def
dropDatabase(callback: MongoCallback1[CommandResult]): Unit
Drop a database, removing it permanently from the server.
Drop a database, removing it permanently from the server.
- callback
the callback containing a reference to this instance
-
def
dropDatabase(): Promise[CommandResult]
Drop a database, removing it permanently from the server.
Drop a database, removing it permanently from the server.
- returns
the promise of the result
-
def
ensureIndex(name: String, fieldOrSpec: |[String, Any], callback: MongoCallback1[CommandResult]): Unit
Ensures that an index exists, if it does not it creates it
Ensures that an index exists, if it does not it creates it
- name
the name of the collection to create the index on.
- fieldOrSpec
defines the index.
- callback
the results callback
-
def
ensureIndex(name: String, fieldOrSpec: |[String, Any], options: |[IndexOptions, RawOptions], callback: MongoCallback1[CommandResult]): Unit
Ensures that an index exists, if it does not it creates it
Ensures that an index exists, if it does not it creates it
- name
the name of the collection to create the index on.
- fieldOrSpec
defines the index.
- options
the optional settings.
- callback
the results callback
-
def
ensureIndex(name: String, fieldOrSpec: |[String, Any], options: |[IndexOptions, RawOptions] = js.native): Promise[CommandResult]
Ensures that an index exists, if it does not it creates it
Ensures that an index exists, if it does not it creates it
- name
the name of the collection to create the index on.
- fieldOrSpec
defines the index.
- options
the optional settings.
- returns
the promise of the result
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
eval(code: Code, parameters: |[Array[String], Any], callback: MongoCallback1[CommandResult]): Unit
Evaluate JavaScript on the server
Evaluate JavaScript on the server
- code
JavaScript to execute on server.
- parameters
The parameters for the call.
- callback
the results callback
-
def
eval(code: Code, parameters: |[Array[String], Any], options: RawOptions, callback: MongoCallback1[CommandResult]): Unit
Evaluate JavaScript on the server
Evaluate JavaScript on the server
- code
JavaScript to execute on server.
- parameters
The parameters for the call.
- options
the optional settings.
- callback
the results callback
-
def
eval(code: Code, parameters: |[Array[String], Any], options: RawOptions = js.native): Promise[CommandResult]
Evaluate JavaScript on the server
Evaluate JavaScript on the server
- code
JavaScript to execute on server.
- parameters
The parameters for the call.
- options
the optional settings.
- returns
the promise of the result
-
def
executeDbAdminCommand(command: Any, callback: MongoCallback1[CommandResult]): Unit
Runs a command on the database as admin.
Runs a command on the database as admin.
- command
the command hash
- callback
the results callback
-
def
executeDbAdminCommand(command: Any, options: |[ReadPreferenceOptions, RawOptions], callback: MongoCallback1[CommandResult]): Unit
Runs a command on the database as admin.
Runs a command on the database as admin.
- command
the command hash
- options
the optional settings.
- callback
the results callback
-
def
executeDbAdminCommand(command: Any, options: |[ReadPreferenceOptions, RawOptions] = js.native): Promise[CommandResult]
Runs a command on the database as admin.
Runs a command on the database as admin.
- command
the command hash
- options
the optional settings.
- returns
the promise of the result
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hasOwnProperty(v: String): Boolean
- Definition Classes
- Object
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
indexInformation(name: String, callback: Function2[MongoError, Any, Any]): Unit
Retrieves this collections index info.
Retrieves this collections index info.
- name
the name of the collection.
- callback
the callback containing the index information
-
def
indexInformation(name: String, options: |[IndexInformationOptions, RawOptions], callback: Function2[MongoError, Any, Any]): Unit
Retrieves this collections index info.
Retrieves this collections index info.
- name
the name of the collection.
- options
the optional settings.
- callback
the callback containing the index information
-
def
indexInformation(name: String, options: |[IndexInformationOptions, RawOptions] = js.native): Promise[Any]
Retrieves this collections index info.
Retrieves this collections index info.
- name
the name of the collection.
- options
the optional settings.
- returns
a promise of the index information
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
-
def
listCollections(filter: Any = js.native, options: |[ListCollectionsOptions, RawOptions] = js.native): CommandCursor[CollectionInfo]
Get the list of all collection information for the specified db.
Get the list of all collection information for the specified db.
- filter
query to filter collections by
- options
the qptional settings.
- returns
a CommandCursor containing the results
-
def
logout(callback: MongoCallback1[CommandResult]): Unit
Logout user from server, fire off on all connections and remove all auth info
Logout user from server, fire off on all connections and remove all auth info
- callback
the command result callback
-
def
logout(options: RawOptions, callback: MongoCallback1[CommandResult]): Unit
Logout user from server, fire off on all connections and remove all auth info
Logout user from server, fire off on all connections and remove all auth info
- options
the optional settings.
- callback
the command result callback
-
def
logout(options: RawOptions): Promise[CommandResult]
Logout user from server, fire off on all connections and remove all auth info
Logout user from server, fire off on all connections and remove all auth info
- options
the optional settings.
- returns
the promise of the result
- var native_parser: Boolean
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
open(callback: MongoCallback1[Db]): Unit
Open the database
Open the database
- callback
the callback
-
def
open(): Promise[Db]
Open the database
Open the database
- returns
the promise of a Db
- val options: DbOptions
-
def
propertyIsEnumerable(v: String): Boolean
- Definition Classes
- Object
-
def
removeUser(username: String, callback: MongoCallback1[CommandResult]): Unit
Remove a user from a database
Remove a user from a database
- username
the username.
- callback
the command result callback
-
def
removeUser(username: String, options: |[RemoveUserOptions, RawOptions], callback: MongoCallback1[CommandResult]): Unit
Remove a user from a database
Remove a user from a database
- username
the username.
- options
the optional settings.
- callback
the command result callback
-
def
removeUser(username: String, options: |[RemoveUserOptions, RawOptions] = js.native): Promise[CommandResult]
Remove a user from a database
Remove a user from a database
- username
the username.
- options
the optional settings.
- returns
the promise of the result
-
def
renameCollection(fromCollection: String, toCollection: String, callback: MongoCallback1[CommandResult]): Unit
Rename a collection.
Rename a collection.
- fromCollection
the name of current collection to rename.
- toCollection
the new name of of the collection.
- callback
the results callback
-
def
renameCollection(fromCollection: String, toCollection: String, options: |[RenameOptions, RawOptions], callback: MongoCallback1[CommandResult]): Unit
Rename a collection.
Rename a collection.
- fromCollection
the name of current collection to rename.
- toCollection
the new name of of the collection.
- options
the optional settings.
- callback
the results callback
-
def
renameCollection(fromCollection: String, toCollection: String, options: |[RenameOptions, RawOptions] = js.native): Promise[CommandResult]
Rename a collection.
Rename a collection.
- fromCollection
the name of current collection to rename.
- toCollection
the new name of of the collection.
- options
the optional settings.
- returns
the promise of the result
- val replicaSet: ReplSet
- var serverConfig: Any
- var slaveOk: Boolean
-
def
stats(callback: MongoCallback1[DbStats]): Unit
Get all the db statistics.
Get all the db statistics.
- callback
the collection result callback
-
def
stats(options: |[DbStatsOptions, RawOptions], callback: MongoCallback1[DbStats]): Unit
Get all the db statistics.
Get all the db statistics.
- options
the optional settings.
- callback
the collection result callback
-
def
stats(options: |[DbStatsOptions, RawOptions] = js.native): MongoCallback1[DbStats]
Get all the db statistics.
Get all the db statistics.
- options
the optional settings.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toLocaleString(): String
- Definition Classes
- Object
-
def
toString(): String
- Definition Classes
- AnyRef → Any
- var topology: Any
-
def
unref(): Unit
Unref all sockets
-
def
valueOf(): Any
- Definition Classes
- Object
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- var writeConcern: Any