InsertOperations¶
interface InsertOperations<Document : Any> : BaseOperations
The different MongoDB operations related to inserting documents.
Inheritors¶
Properties¶
context¶
abstract val context: BsonContext
The full BSON configuration, used by the DSL to generate queries.
For more information, see BsonContext.
factory¶
abstract val factory: BsonFactory
The BsonFactory used to serialize and deserialize values.
This property stores all serialization configurations and allows creating custom BSON objects.
For more information, see BsonFactory.
objectIdGenerator¶
abstract val objectIdGenerator: ObjectIdGenerator
The algorithm used to generate new ObjectId instances.
For more information, see ObjectIdGenerator.
propertyNameStrategy¶
abstract val propertyNameStrategy: PropertyNameStrategy
The strategy used to convert property names to BSON document keys.
For more information, see PropertyNameStrategy.
Functions¶
insertMany¶
abstract fun insertMany(documents: Iterable<Document>, options: InsertManyOptions<Document>.() -> Unit = {})
open fun insertMany(vararg documents: Document, options: InsertManyOptions<Document>.() -> Unit = {})
Inserts multiple documents in a single operation.
Example
class User(
val name: String,
val age: Int,
)
collection.insertMany(
User(name = "Bob", age = 18),
User(name = "Alice", age = 17)
)
Filtered collections
Insert operations ignore the configured filter: the document will be inserted even if it does not match the filter.
External resources
See also
insertOne: Insert a single document.
insertOne¶
abstract fun insertOne(document: Document, options: InsertOneOptions<Document>.() -> Unit = {})
Inserts a document.
Example
Filtered collections
Insert operations ignore the configured filter: the document will be inserted even if it does not match the filter.
External resources
See also
insertMany: Insert multiple documents.