CollectionOperations¶
interface CollectionOperations<Document : Any> : BaseOperations
Interface grouping MongoDB operations relating to collection administration.
Inheritors¶
Properties¶
context¶
@LowLevelApi
abstract val context: BsonContext
The full BSON configuration, used by the DSL to generate queries.
For more information, see BsonContext.
Functions¶
create¶
abstract suspend fun create(options: CreateCollectionOptions<Document>.() -> Unit = {})
Explicitly creates this collection.
MongoDB will automatically create a collection with default settings on the first write operation. This method is useful to create a collection with non-default settings.
If this method is called and the collection already exists with the same options, nothing happens. If this method is called and the collection already exists with different options, an error is thrown.
Example
Create a capped collection: a collection with a maximum size on disk:
External resources
drop¶
abstract suspend fun drop(options: DropOptions<Document>.() -> Unit = {})
Removes an entire collection from the database.
All documents within the collection are deleted.
Indexes attached to this collection are also deleted.
Example
External resources