DbCollection class

Constructors

DbCollection(Db db, String collectionName)

Properties

collectionName String
getter/setter pair
db Db
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
readPreference ReadPreference
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

aggregate(List pipeline, {bool allowDiskUse = false, Map<String, Object>? cursor}) Future<Map<String, dynamic>>
Old version to be used on MongoDb versions prior to 3.6
aggregateToStream(List<Map<String, Object>> pipeline, {Map<String, Object> cursorOptions = const <String, Object>{}, bool allowDiskUse = false}) Stream<Map<String, dynamic>>
Executes an aggregation pipeline
bulkWrite(List<Map<String, Object>> documents, {bool ordered = true, WriteConcern? writeConcern}) Future<BulkWriteResult>
count([dynamic selector]) Future<int>
createCursor([dynamic selector]) Cursor
createIndex({String? key, Map<String, dynamic>? keys, bool? unique, bool? sparse, bool? background, bool? dropDups, Map<String, dynamic>? partialFilterExpression, String? name, bool? modernReply}) Future<Map<String, dynamic>>
This function is provided for all servers starting from version 3.6 For previous releases use the same method on Db class.
deleteMany(dynamic selector, {WriteConcern? writeConcern, CollationOptions? collation, String? hint, Map<String, Object>? hintDocument}) Future<WriteResult>
deleteOne(dynamic selector, {WriteConcern? writeConcern, CollationOptions? collation, String? hint, Map<String, Object>? hintDocument}) Future<WriteResult>
distinct(String field, [dynamic selector]) Future<Map<String, dynamic>>
drop() Future<bool>
dropIndexes(Object index, {WriteConcern? writeConcern, String? comment, Map<String, Object>? rawOptions}) Future<Map<String, dynamic>>
find([dynamic selector]) Stream<Map<String, dynamic>>
Creates a cursor for a query that can be used to iterate over results from MongoDB ##selector parameter represents query to locate objects. If omitted as in find() then query matches all documents in colleciton. Here's a more selective example: find({'last_name': 'Smith'}) Here our selector will match every document where the last_name attribute is 'Smith.'
findAndModify({dynamic query, dynamic sort, bool? remove, dynamic update, bool? returnNew, dynamic fields, bool? upsert}) Future<Map<String, dynamic>?>
Modifies and returns a single document. By default, the returned document does not include the modifications made on the update. To return the document with the modifications made on the update, use the returnNew option.
findOne([dynamic selector]) Future<Map<String, dynamic>?>
Returns one document that satisfies the specified query criteria on the collection or view. If multiple documents satisfy the query, this method returns the first document.
fullName() String
getIndexes() Future<List<Map<String, dynamic>>>
Analogue of mongodb shell method db.collection.getIndexes() Returns an array that holds a list of documents that identify and describe the existing indexes on the collection. You must call getIndexes() on a collection
insert(Map<String, dynamic> document, {WriteConcern? writeConcern}) Future<Map<String, dynamic>>
Inserts a document into a collection
insertAll(List<Map<String, dynamic>> documents, {WriteConcern? writeConcern}) Future<Map<String, dynamic>>
Allows to insert many documents at a time. This is the legacy version of the insertMany() method
insertMany(List<Map<String, dynamic>> documents, {WriteConcern? writeConcern, bool? ordered, bool? bypassDocumentValidation}) Future<BulkWriteResult>
insertOne(Map<String, dynamic> document, {WriteConcern? writeConcern, bool? bypassDocumentValidation}) Future<WriteResult>
legacyAggregateToStream(List pipeline, {Map<String, dynamic> cursorOptions = const {}, bool allowDiskUse = false}) Stream<Map<String, dynamic>>
Old version to be used on MongoDb versions prior to 3.6
legacyCount([dynamic selector]) Future<int>
legacyDistinct(String field, [dynamic selector]) Future<Map<String, dynamic>>
Old version to be used on MongoDb versions prior to 3.6
legacyFind([dynamic selector]) Stream<Map<String, dynamic>>
legacyFindAndModify({dynamic query, dynamic sort, bool? remove, dynamic update, bool? returnNew, dynamic fields, bool? upsert}) Future<Map<String, dynamic>?>
legacyFindOne([dynamic selector]) Future<Map<String, dynamic>?>
legacyInsert(Map<String, dynamic> document, {WriteConcern? writeConcern}) Future<Map<String, dynamic>>
Old version to be used on MongoDb versions prior to 3.6
legacyInsertAll(List<Map<String, dynamic>> documents, {WriteConcern? writeConcern}) Future<Map<String, dynamic>>
Allows to insert many documents at a time. This is the legacy version of the insertMany() method
legacyRemove(dynamic selector, {WriteConcern? writeConcern}) Future<Map<String, dynamic>>
legacyUpdate(dynamic selector, dynamic document, {bool upsert = false, bool multiUpdate = false, WriteConcern? writeConcern}) Future<Map<String, dynamic>>
listIndexes({int? batchSize, String? comment, Map<String, Object>? rawOptions}) Stream<Map<String, dynamic>>
modernAggregate(dynamic pipeline, {bool? explain, Map<String, Object>? cursor, String? hint, Map<String, Object>? hintDocument, AggregateOptions? aggregateOptions, Map<String, Object>? rawOptions}) Stream<Map<String, dynamic>>
This method returns a stream that can be read or transformed into a list with .toList()
modernAggregateCursor(dynamic pipeline, {bool? explain, Map<String, Object>? cursor, String? hint, Map<String, Object>? hintDocument, AggregateOptions? aggregateOptions, Map<String, Object>? rawOptions}) → ModernCursor
This method returns a curosr that can be read or transformed into a stream with stream (for a stream you can directly call modernAggregate)
modernCount({SelectorBuilder? selector, Map<String, dynamic>? filter, int? limit, int? skip, CollationOptions? collation, String? hint, Map<String, Object>? hintDocument, CountOptions? countOptions, Map<String, Object>? rawOptions}) Future<CountResult>
modernDistinct(String field, {dynamic query, DistinctOptions? distinctOptions, Map<String, Object>? rawOptions}) Future<DistinctResult>
Executes a Distinct command on this collection. Retuns a DistinctResult class.
modernDistinctMap(String field, {dynamic query, DistinctOptions? distinctOptions, Map<String, Object>? rawOptions}) Future<Map<String, dynamic>>
Executes a Distinct command on this collection. Retuns a Map like received from the server. Used for compatibility with the legacy method
modernFind({SelectorBuilder? selector, Map<String, dynamic>? filter, Map<String, Object>? sort, Map<String, Object>? projection, String? hint, Map<String, Object>? hintDocument, int? skip, int? limit, FindOptions? findOptions, Map<String, Object>? rawOptions}) Stream<Map<String, dynamic>>
modernFindAndModify({dynamic query, dynamic sort, bool? remove, dynamic update, bool? returnNew, dynamic fields, bool? upsert, List? arrayFilters, String? hint, Map<String, Object>? hintDocument, FindAndModifyOptions? findAndModifyOptions, Map<String, Object>? rawOptions}) Future<FindAndModifyResult>
modernFindOne({SelectorBuilder? selector, Map<String, dynamic>? filter, Map<String, Object>? sort, Map<String, Object>? projection, String? hint, Map<String, Object>? hintDocument, int? skip, FindOptions? findOptions, Map<String, Object>? rawOptions}) Future<Map<String, dynamic>?>
Returns one document that satisfies the specified query criteria on the collection or view. If multiple documents satisfy the query, this method returns the first document according to the sort order or the natural order of sort parameter is not specified. In capped collections, natural order is the same as insertion order. If no document satisfies the query, the method returns null.
modernUpdate(dynamic selector, dynamic update, {bool? upsert, bool? multi, WriteConcern? writeConcern, CollationOptions? collation, List? arrayFilters, String? hint, Map<String, Object>? hintDocument}) Future<Map<String, dynamic>>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(dynamic selector, {WriteConcern? writeConcern}) Future<Map<String, dynamic>>
Removes documents from a collection.
replaceOne(dynamic selector, Map<String, dynamic> update, {bool? upsert, WriteConcern? writeConcern, CollationOptions? collation, String? hint, Map<String, Object>? hintDocument}) Future<WriteResult>
save(Map<String, dynamic> document, {WriteConcern? writeConcern}) Future<Map<String, dynamic>>
toString() String
A string representation of this object.
inherited
update(dynamic selector, dynamic document, {bool upsert = false, bool multiUpdate = false, WriteConcern? writeConcern}) Future<Map<String, dynamic>>
Modifies an existing document or documents in a collection. The method can modify specific fields of an existing document or documents or replace an existing document entirely, depending on the document parameter.
updateMany(dynamic selector, dynamic update, {bool? upsert, WriteConcern? writeConcern, CollationOptions? collation, List? arrayFilters, String? hint, Map<String, Object>? hintDocument}) Future<WriteResult>
updateOne(dynamic selector, dynamic update, {bool? upsert, WriteConcern? writeConcern, CollationOptions? collation, List? arrayFilters, String? hint, Map<String, Object>? hintDocument}) Future<WriteResult>
watch(Object pipeline, {int? batchSize, String? hint, Map<String, Object>? hintDocument, ChangeStreamOptions? changeStreamOptions, Map<String, Object>? rawOptions}) Stream
watchCursor(Object pipeline, {int? batchSize, String? hint, Map<String, Object>? hintDocument, ChangeStreamOptions? changeStreamOptions, Map<String, Object>? rawOptions}) → ModernCursor

Operators

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