Db class

Constructors

Db(String uriString, [String? _debugInfo])
Db constructor expects valid mongodb URI. For example next code points to local mongodb server on default mongodb port, database testdb
Db.pool(List<String> uriList, [String? _debugInfo])

Properties

authSourceDb Db?
getter/setter pair
databaseName String?
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isConnected bool
Is connected returns true if the database is in state OPEN and at least the primary connection is connected
no setter
masterConnection Connection
no setter
masterConnectionAnyState Connection
no setter
readPreference ReadPreference
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state State
getter/setter pair
uriList List<String>
no setter
writeConcern WriteConcern?
no setter

Methods

aggregate(List<Map<String, Object>> pipeline, {bool? explain, Map<String, Object>? cursor, String? hint, Map<String, Object>? hintDocument, AggregateOptions? aggregateOptions, Map<String, Object>? rawOptions}) Stream<Map<String, dynamic>>
Runs a specified admin/diagnostic pipeline which does not require an underlying collection. For aggregations on collection data, see dbcollection.modernAggregate().
authenticate(String? userName, String? password, {Connection? connection, AuthenticationScheme? authScheme, String? authDb}) Future<bool>
authenticateX509({Connection? connection}) Future<bool>
Method for authentication with X509 certificate. In the conection parameters you have not to set X509 if you want to use this delayed auth function.
close() Future
collection(String collectionName) DbCollection
collectionsInfoCursor([String? collectionName]) Stream<Map<String, dynamic>>
This method uses system collections and therefore do not work on MongoDB v3.0 with and upward with WiredTiger Use getCollectionInfos instead
createCollection(String name, {CreateCollectionOptions? createCollectionOptions, Map<String, Object>? rawOptions}) Future<Map<String, dynamic>>
This method explicitly creates a collection
createIndex(String collectionName, {String? key, Map<String, dynamic>? keys, bool? unique, bool? sparse, bool? background, bool? dropDups, Map<String, dynamic>? partialFilterExpression, String? name}) Future<Map<String, dynamic>>
createView(String view, String source, List pipeline, {CreateViewOptions? createViewOptions, Map<String, Object>? rawOptions}) Future<Map<String, dynamic>>
This method creates a view
documentIsNotAnError(dynamic firstRepliedDocument) bool
drop() Future
Drop current database
dropCollection(String collectionName) Future<bool>
ensureIndex(String collectionName, {String? key, Map<String, dynamic>? keys, bool? unique, bool? sparse, bool? background, bool? dropDups, Map<String, dynamic>? partialFilterExpression, String? name}) Future
executeDbCommand(MongoMessage message, {Connection? connection}) Future<Map<String, dynamic>>
executeMessage(MongoMessage message, WriteConcern? writeConcern, {Connection? connection}) → void
executeModernMessage(MongoModernMessage message, {Connection? connection, bool skipStateCheck = false}) Future<Map<String, dynamic>>
getBuildInfo({Connection? connection}) Future<Map<String, dynamic>>
getCollectionInfos([Map<String, dynamic> filter = const {}]) Future<List<Map<String, dynamic>>>
getCollectionNames([Map<String, dynamic> filter = const {}]) Future<List<String?>>
getLastError([WriteConcern? writeConcern]) Future<Map<String, dynamic>>
getNonce({Connection? connection}) Future<Map<String, dynamic>>
indexInformation([String? collectionName]) Future<List>
This method uses system collections and therefore do not work on MongoDB v3.0 with and upward with WiredTiger Use DbCollection.getIndexes() instead
isMaster({Connection? connection}) Future<Map<String, dynamic>>
listCollections() Future<List<String?>>
Analogue to shell's show collections This method uses system collections and therefore do not work on MongoDB v3.0 with and upward with WiredTiger Use getCollectionNames instead
listDatabases() Future<List>
Analogue to shell's show dbs. Helper for listDatabases mongodb command.
modernDrop(String collectionNAme, {DropOptions? dropOptions, Map<String, Object>? rawOptions}) Future<Map<String, dynamic>>
This method drops a collection
modernDropDatabase({DropDatabaseOptions? dropOptions, Map<String, Object>? rawOptions}) Future<Map<String, dynamic>>
This method drops the current DB
modernListCollections({SelectorBuilder? selector, Map<String, dynamic>? filter, ListCollectionsOptions? findOptions, Map<String, Object>? rawOptions}) Stream<Map<String, dynamic>>
This method retuns a cursor to get a list of the collections for this DB.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open({WriteConcern writeConcern = WriteConcern.acknowledged, bool secure = false, bool tlsAllowInvalidCertificates = false, String? tlsCAFile, String? tlsCertificateKeyFile, String? tlsCertificateKeyFilePassword}) Future
pingCommand() Future<Map<String, dynamic>>
Ping command
queryMessage(MongoMessage queryMessage, {Connection? connection}) Future<MongoReplyMessage>
removeFromCollection(String collectionName, [Map<String, dynamic> selector = const {}, WriteConcern? writeConcern]) Future<Map<String, dynamic>>
runCommand(Map<String, Object>? command) Future<Map<String, dynamic>>
Runs a command
selectAuthenticationMechanism(String authenticationSchemeName) → void
serverStatus({Map<String, Object>? options}) Future<Map<String, dynamic>>
This method return the status information on the connection.
toString() String
A string representation of this object.
override
wait() Future<Map<String, dynamic>>

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

create(String uriString, [String? debugInfo]) Future<Db>
This method allow to create a Db object both with the Standard Connection String Format (mongodb://) or with the DNS Seedlist Connection Format (mongodb+srv://). The former has the format: mongodb://username:password@host1:port1 [,...hostN:portN][/?options] The latter is available from version 3.6. The format is: mongodb+srv://username:password@host1:port1 [/?options] More info are available here

Constants

mongoDefaultPort → const int