fun <T : Any> MongoCollection<T>.save(document: T): Unit
(source)
Save the document. If the document has no id field, or if the document has a null id value, insert the document. Otherwise, call replaceOneById with upsert true.
document
- the document to save
com.mongodb.MongoWriteException
- if the write failed due some other failure specific to the update command
com.mongodb.MongoWriteConcernException
- if the write failed due being unable to fulfil the write concern
com.mongodb.MongoException
- if the write failed due some other failure
fun <T : Any> MongoCollection<T>.save(clientSession: ClientSession, document: T): Unit
(source)
Save the document. If the document has no id field, or if the document has a null id value, insert the document. Otherwise, call replaceOneById with upsert true.
clientSession
- the client session with which to associate this operation
document
- the document to save
com.mongodb.MongoWriteException
- if the write failed due some other failure specific to the update command
com.mongodb.MongoWriteConcernException
- if the write failed due being unable to fulfil the write concern
com.mongodb.MongoException
- if the write failed due some other failure