InsertOperations¶
interface InsertOperations<Document> : BaseOperations
Interface grouping MongoDB operations relating to inserting new documents.
Inheritors¶
Properties¶
context¶
@LowLevelApi
abstract val context: BsonContext
Functions¶
insertMany¶
abstract fun insertMany(documents: Iterable<Document>, options: InsertManyOptions<Document>.() -> Unit = {})
Inserts multiple documents in a single operation.
Example¶
Note that insertOne ignores filtered collection. That is, insertOne on a filtered collection behaves exactly the same as the same insertOne on the underlying real collection.
External resources¶
See also
InsertOperations.insertOne: Insert a single document.
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)
)
Note that insertOne ignores filtered collection. That is, insertOne on a filtered collection behaves exactly the same as the same insertOne on the underlying real collection.
External resources¶
See also
InsertOperations.insertOne: Insert a single document.
insertOne¶
abstract fun insertOne(document: Document, options: InsertOneOptions<Document>.() -> Unit = {})
Inserts a document.
Example¶
Note that insertOne ignores filtered collection. That is, insertOne on a filtered collection behaves exactly the same as the same insertOne on the underlying real collection.
External resources¶
See also
InsertOperations.insertMany: Insert multiple documents.