CreateCollectionCommand class

createCollection command.

Explicitly creates a collection.

Because MongoDB creates a collection implicitly when the collection is first referenced in a command, this method is used primarily for creating new collections that use specific options. For example, you use db.createCollection() to create a capped collection, or to create a new collection that uses document validation.

Starting in MongoDB 4.2

MongoDB removes the MMAPv1 storage engine and the MMAPv1 specific options paddingFactor, paddingBytes, preservePadding for db.createCollection().

Note

The Original shell command allows to create also views. We restrict this behavior and you will need the db.createView() (or directly the CreateCommand) to create one.

The command accepts the following fields:

  • db Db The database on which create the collection
  • name String The collection name to be created.
  • createCollectionOptions createCollectionOptions - Optional a set of optional values for the command
  • rawOption Map An alternative way to creteCollectionOptions to specify command options (must be manually set)

Constructors

CreateCollectionCommand(Db db, String name, {CreateCollectionOptions? createCollectionOptions, Map<String, Object>? rawOptions})

Properties

canRetryRead bool
no setterinherited
collection DbCollection?
getter/setter pairinherited
command Map<String, Object>?
getter/setter pairinherited
connection Connection?
getter/setter pairinherited
db Db
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
options Map<String, Object>
getter/setter pairinherited
readPreference ReadPreference?
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
session Object?
getter/setter pairinherited

Methods

$buildCommand() Map<String, Object>
inherited
clearSession() → void
inherited
execute({bool skipStateCheck = false}) Future<Map<String, dynamic>>
inherited
hasAspect(Aspect aspect) bool
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
processOptions(Map<String, dynamic> command) → void
inherited
toString() String
A string representation of this object.
inherited

Operators

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