insertOne

abstract suspend fun insertOne(document: Document, options: InsertOneOptions<Document>.() -> Unit = {})(source)

Inserts a document.

Example

class User(
val name: String,
val age: Int,
)

collection.insertOne(User(name = "Bob", age = 18))

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

Insert multiple documents.