public class MongoCollectionsWithClientSessionKt
public static <T> long countDocuments(@NotNull
com.mongodb.client.MongoCollection<T> $this$countDocuments,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter,
@NotNull
com.mongodb.client.model.CountOptions options)
Counts the number of documents in the collection according to the given options.
clientSession - the client session with which to associate this operationfilter - the query filteroptions - the options describing the count@NotNull
public static <T> com.mongodb.client.FindIterable<T> find(@NotNull
com.mongodb.client.MongoCollection<T> $this$find,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter)
Finds all documents in the collection.
clientSession - the client session with which to associate this operationfilter - the query filter@NotNull
public static <T> com.mongodb.client.FindIterable<T> find(@NotNull
com.mongodb.client.MongoCollection<T> $this$find,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
org.bson.conversions.Bson... filters)
Finds all documents in the collection.
clientSession - the client session with which to associate this operationfilters - the query filters@Nullable
public static <T> T findOne(@NotNull
com.mongodb.client.MongoCollection<T> $this$findOne,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter)
Finds the first document that match the filter in the collection.
clientSession - the client session with which to associate this operationfilter - the query filter@Nullable
public static <T> T findOne(@NotNull
com.mongodb.client.MongoCollection<T> $this$findOne,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
org.bson.conversions.Bson filter)
Finds the first document that match the filter in the collection.
clientSession - the client session with which to associate this operationfilter - the query filter@Nullable
public static <T> T findOne(@NotNull
com.mongodb.client.MongoCollection<T> $this$findOne,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
org.bson.conversions.Bson... filters)
Finds the first document that match the filters in the collection.
clientSession - the client session with which to associate this operationfilters - the query filters@Nullable
public static <T> T findOneById(@NotNull
com.mongodb.client.MongoCollection<T> $this$findOneById,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.Object id)
Finds the document that match the id parameter.
clientSession - the client session with which to associate this operationid - the object id@NotNull
public static <T> com.mongodb.client.result.DeleteResult deleteOne(@NotNull
com.mongodb.client.MongoCollection<T> $this$deleteOne,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter)
Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.
clientSession - the client session with which to associate this operationfilter - the query filter to apply the the delete operationcom.mongodb.MongoWriteException - if the write failed due some other failure specific to the delete commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.DeleteResult deleteOne(@NotNull
com.mongodb.client.MongoCollection<T> $this$deleteOne,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
org.bson.conversions.Bson... filters)
Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.
clientSession - the client session with which to associate this operationfilters - the query filters to apply the the delete operationcom.mongodb.MongoWriteException - if the write failed due some other failure specific to the delete commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.DeleteResult deleteOneById(@NotNull
com.mongodb.client.MongoCollection<T> $this$deleteOneById,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.Object id)
Removes at most one document from the id parameter. If no documents match, the collection is not modified.
clientSession - the client session with which to associate this operationid - the object idcom.mongodb.MongoWriteException - if the write failed due some other failure specific to the delete commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.DeleteResult deleteMany(@NotNull
com.mongodb.client.MongoCollection<T> $this$deleteMany,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter,
@NotNull
com.mongodb.client.model.DeleteOptions options)
Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.
clientSession - the client session with which to associate this operationfilter - the query filter to apply the the delete operationoptions - the options to apply to the delete operationcom.mongodb.MongoWriteException - if the write failed due some other failure specific to the delete commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.DeleteResult deleteMany(@NotNull
com.mongodb.client.MongoCollection<T> $this$deleteMany,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
org.bson.conversions.Bson[] filters,
@NotNull
com.mongodb.client.model.DeleteOptions options)
Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.
clientSession - the client session with which to associate this operationfilters - the query filters to apply the the delete operationoptions - the options to apply to the delete operationcom.mongodb.MongoWriteException - if the write failed due some other failure specific to the delete commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failurepublic static <T> void save(@NotNull
com.mongodb.client.MongoCollection<T> $this$save,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
T document)
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 operationdocument - the document to savecom.mongodb.MongoWriteException - if the write failed due some other failure specific to the update commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failurereplaceOneById@NotNull
public static <T> com.mongodb.client.result.UpdateResult replaceOneById(@NotNull
com.mongodb.client.MongoCollection<T> $this$replaceOneById,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.Object id,
@NotNull
T replacement,
@NotNull
com.mongodb.client.model.ReplaceOptions options)
Replace a document in the collection according to the specified arguments.
clientSession - the client session with which to associate this operationid - the object idreplacement - the replacement documentoptions - the options to apply to the replace operationcom.mongodb.MongoWriteException - if the write failed due some other failure specific to the update commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.UpdateResult replaceOne(@NotNull
com.mongodb.client.MongoCollection<T> $this$replaceOne,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter,
@NotNull
T replacement,
@NotNull
com.mongodb.client.model.ReplaceOptions options)
Replace a document in the collection according to the specified arguments.
clientSession - the client session with which to associate this operationfilter - the query filter to apply to the replace operationreplacement - the replacement documentoptions - the options to apply to the replace operationcom.mongodb.MongoWriteException - if the write failed due some other failure specific to the update commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.UpdateResult replaceOneWithFilter(@NotNull
com.mongodb.client.MongoCollection<T> $this$replaceOneWithFilter,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
org.bson.conversions.Bson filter,
@NotNull
T replacement,
@NotNull
com.mongodb.client.model.ReplaceOptions replaceOptions)
Replace a document in the collection according to the specified arguments.
Same than MongoCollection.replaceOne but ensure that any _id present
in replacement is removed to avoid MongoWriteException such as:
"After applying the update, the (immutable) field '_id' was found to have been altered to _id"
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
clientSession - the client session with which to associate this operationfilter - the query filter to apply the the replace operationreplacement - the replacement documentreplaceOptions - the options to apply to the replace operationcom.mongodb.MongoWriteException - if the write failed due some other failure specific to the replace commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failurereplacement@NotNull
public static <T> com.mongodb.client.result.UpdateResult updateOne(@NotNull
com.mongodb.client.MongoCollection<T> $this$updateOne,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter,
@NotNull
java.lang.String update,
@NotNull
com.mongodb.client.model.UpdateOptions options)
Update a single document in the collection according to the specified arguments.
clientSession - the client session with which to associate this operationfilter - a document describing the query filterupdate - a document describing the update. The update to apply must include only update operators.options - the options to apply to the update operationcom.mongodb.MongoWriteException - if the write failed due some other failure specific to the update commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.UpdateResult updateOne(@NotNull
com.mongodb.client.MongoCollection<T> $this$updateOne,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter,
@NotNull
java.lang.Object update,
@NotNull
com.mongodb.client.model.UpdateOptions options,
boolean updateOnlyNotNullProperties)
Update a single document in the collection according to the specified arguments.
clientSession - the client session with which to associate this operationfilter - a document describing the query filterupdate - the update objectoptions - the options to apply to the update operationupdateOnlyNotNullProperties - if true do not change null propertiescom.mongodb.MongoWriteException - if the write failed due some other failure specific to the update commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.UpdateResult updateOne(@NotNull
com.mongodb.client.MongoCollection<T> $this$updateOne,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
org.bson.conversions.Bson filter,
@NotNull
java.lang.Object target,
@NotNull
com.mongodb.client.model.UpdateOptions options,
boolean updateOnlyNotNullProperties)
Update a single document in the collection according to the specified arguments.
clientSession - the client session with which to associate this operationfilter - a document describing the query filteroptions - the options to apply to the update operationupdateOnlyNotNullProperties - if true do not change null propertiescom.mongodb.MongoWriteException - if the write failed due some other failure specific to the update commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.UpdateResult updateOne(@NotNull
com.mongodb.client.MongoCollection<T> $this$updateOne,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
org.bson.conversions.Bson filter,
@NotNull
org.litote.kmongo.SetTo[] updates,
@NotNull
com.mongodb.client.model.UpdateOptions updateOptions)
Update a single document in the collection according to the specified arguments.
clientSession - the client session with which to associate this operationfilter - a document describing the query filterupdates - the setTo describing the updatescom.mongodb.MongoWriteException - if the write failed due some other failure specific to the update commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.UpdateResult updateOneById(@NotNull
com.mongodb.client.MongoCollection<T> $this$updateOneById,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.Object id,
@NotNull
java.lang.Object update,
@NotNull
com.mongodb.client.model.UpdateOptions options,
boolean updateOnlyNotNullProperties)
Update a single document in the collection according to the specified arguments.
clientSession - the client session with which to associate this operationid - the object idupdate - the update objectoptions - the options to apply to the update operationupdateOnlyNotNullProperties - if true do not change null propertiescom.mongodb.MongoWriteException - if the write failed due some other failure specific to the update commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.UpdateResult updateMany(@NotNull
com.mongodb.client.MongoCollection<T> $this$updateMany,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter,
@NotNull
java.lang.String update,
@NotNull
com.mongodb.client.model.UpdateOptions updateOptions)
Update all documents in the collection according to the specified arguments.
clientSession - the client session with which to associate this operationfilter - a document describing the query filter, which may not be null.update - a document describing the update, which may not be null. The update to apply must include only update operators.updateOptions - the options to apply to the update operationcom.mongodb.MongoWriteException - if the write failed due some other failure specific to the update commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@NotNull
public static <T> com.mongodb.client.result.UpdateResult updateMany(@NotNull
com.mongodb.client.MongoCollection<T> $this$updateMany,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
org.bson.conversions.Bson filter,
@NotNull
org.litote.kmongo.SetTo[] updates,
@NotNull
com.mongodb.client.model.UpdateOptions updateOptions)
Update all documents in the collection according to the specified arguments.
clientSession - the client session with which to associate this operationfilter - a document describing the query filter, which may not be null.updates - a document describing the update, which may not be null. The update to apply must include only update operators.updateOptions - the options to apply to the update operationcom.mongodb.MongoWriteException - if the write failed due some other failure specific to the update commandcom.mongodb.MongoWriteConcernException - if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException - if the write failed due some other failure@Nullable
public static <T> T findOneAndDelete(@NotNull
com.mongodb.client.MongoCollection<T> $this$findOneAndDelete,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter,
@NotNull
com.mongodb.client.model.FindOneAndDeleteOptions options)
Atomically find a document and remove it.
clientSession - the client session with which to associate this operationfilter - the query filter to find the document withoptions - the options to apply to the operation@Nullable
public static <T> T findOneAndReplace(@NotNull
com.mongodb.client.MongoCollection<T> $this$findOneAndReplace,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter,
T replacement,
@NotNull
com.mongodb.client.model.FindOneAndReplaceOptions options)
Atomically find a document and replace it.
clientSession - the client session with which to associate this operationfilter - the query filter to apply the the replace operationreplacement - the replacement documentoptions - the options to apply to the operationreturnOriginal property, this will either be the
document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be
returned@Nullable
public static <T> T findOneAndUpdate(@NotNull
com.mongodb.client.MongoCollection<T> $this$findOneAndUpdate,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String filter,
@NotNull
java.lang.String update,
@NotNull
com.mongodb.client.model.FindOneAndUpdateOptions options)
Atomically find a document and update it.
clientSession - the client session with which to associate this operationfilter - a document describing the query filter, which may not be null.update - a document describing the update, which may not be null. The update to apply must include only update operators.options - the options to apply to the operationreturnOriginal property, this will either be the
document as it was before the update or as it is after the update. If no documents matched the query filter, then null will be
returned@NotNull
public static <T> java.lang.String createIndex(@NotNull
com.mongodb.client.MongoCollection<T> $this$createIndex,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String keys,
@NotNull
com.mongodb.client.model.IndexOptions indexOptions)
Create an index with the given keys and options.
clientSession - the client session with which to associate this operationkeys - an object describing the index key(s), which may not be null.indexOptions - the options for the index@NotNull
public static <T> java.lang.String ensureIndex(@NotNull
com.mongodb.client.MongoCollection<T> $this$ensureIndex,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
org.bson.conversions.Bson keys,
@NotNull
com.mongodb.client.model.IndexOptions indexOptions)
Create an index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.
clientSession - the client session with which to associate this operationkeys - an object describing the index key(s), which may not be null.indexOptions - the options for the index@NotNull
public static <T> java.lang.String ensureIndex(@NotNull
com.mongodb.client.MongoCollection<T> $this$ensureIndex,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
kotlin.reflect.KProperty[] properties,
@NotNull
com.mongodb.client.model.IndexOptions indexOptions)
Create an ascending index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.
clientSession - the client session with which to associate this operationindexOptions - the options for the index@NotNull
public static <T> java.lang.String ensureUniqueIndex(@NotNull
com.mongodb.client.MongoCollection<T> $this$ensureUniqueIndex,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
kotlin.reflect.KProperty[] properties,
@NotNull
com.mongodb.client.model.IndexOptions indexOptions)
Create an IndexOptions.unique index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.
clientSession - the client session with which to associate this operationindexOptions - the options for the index@NotNull
public static <T> java.lang.String ensureIndex(@NotNull
com.mongodb.client.MongoCollection<T> $this$ensureIndex,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String keys,
@NotNull
com.mongodb.client.model.IndexOptions indexOptions)
Create an index with the given keys and options. If the creation of the index is not doable because an index with the same keys but with different IndexOptions already exists, then drop the existing index and create a new one.
clientSession - the client session with which to associate this operationkeys - an object describing the index key(s), which may not be null.indexOptions - the options for the indexpublic static <T> void dropIndex(@NotNull
com.mongodb.client.MongoCollection<T> $this$dropIndex,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String keys)
Drops the index given the keys used to create it.
clientSession - the client session with which to associate this operationkeys - the keys of the index to removepublic static <T> void dropIndexOfKeys(@NotNull
com.mongodb.client.MongoCollection<T> $this$dropIndexOfKeys,
@NotNull
com.mongodb.client.ClientSession clientSession,
@NotNull
java.lang.String json)
Drops the index given the keys used to create it.
clientSession - the client session with which to associate this operationjson - the keys of the index to remove