public final class MongoDbMethods extends Object
Constructor and Description |
---|
MongoDbMethods(io.toro.martini.database.DataSourceManager manager) |
Modifier and Type | Method and Description |
---|---|
static void |
abortTransaction(com.mongodb.client.ClientSession clientSession)
Abort a transaction in the context of this session.
|
static io.toro.gloop.object.cursor.GloopCursor |
aggregate(String connectionName,
String databaseName,
String collectionName,
List<? extends org.bson.conversions.Bson> pipeline,
com.mongodb.client.ClientSession clientSession,
boolean closeClient,
io.toro.gloop.engine.GloopExecutionContext context)
Aggregates documents according to the specified aggregation pipeline.
|
static io.toro.gloop.object.cursor.GloopCursor |
aggregateWithQuery(String connectionName,
String databaseName,
String collectionName,
List<String> pipelineQueries,
com.mongodb.client.ClientSession clientSession,
boolean closeClient,
io.toro.gloop.engine.GloopExecutionContext context)
Aggregates documents according to the specified aggregation pipeline.
|
static io.toro.gloop.object.cursor.GloopCursor |
bulkWrite(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
int batchSize,
boolean closeClient,
boolean ordered,
Boolean bypassDocumentValidation,
io.toro.gloop.engine.GloopExecutionContext context)
Executes a mix of inserts, updates, replaces, and deletes.
|
static void |
commitTransaction(com.mongodb.client.ClientSession clientSession)
Commit a transaction in the context of this session.
|
static MongoDbDataSource |
connection(String connectionName)
Return mongo datasource object
|
String |
connectionToString(String connectionName)
Returns a string representation of the mongo client object.
|
static long |
countDocuments(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
org.bson.conversions.Bson filter)
Counts the number of documents in the collection according to the given options.
|
static long |
countDocuments(String connectionName,
String databaseName,
String collectionName,
String query,
com.mongodb.client.ClientSession clientSession)
Counts the number of documents in the collection according to the given options.
|
static void |
createDatabaseAndCollection(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession)
Create a new collection with the given name.
|
static String |
createIndex(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
org.bson.conversions.Bson keys,
com.mongodb.client.model.IndexOptions indexOptions)
Create an index with the given keys and options.
|
static String |
createIndex(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
String keys,
com.mongodb.client.model.IndexOptions indexOptions)
Create an index with the given keys and options.
|
static List<String> |
createIndexes(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
List<com.mongodb.client.model.IndexModel> indexes,
com.mongodb.client.model.CreateIndexOptions createIndexOptions)
Create multiple indexes.
|
static void |
createView(String connectionName,
String databaseName,
String viewName,
String viewOn,
List<? extends org.bson.conversions.Bson> pipeline,
com.mongodb.client.ClientSession clientSession,
com.mongodb.client.model.CreateViewOptions createViewOptions)
Creates a view with the given name, backing collection/view name, and aggregation pipeline that defines the
view.
|
static com.mongodb.client.result.DeleteResult |
deleteMany(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
org.bson.conversions.Bson filter,
com.mongodb.client.model.DeleteOptions options)
Removes all documents from the collection that match the given query filter.
|
static com.mongodb.client.result.DeleteResult |
deleteMany(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
String filterQuery,
com.mongodb.client.model.DeleteOptions options)
Removes all documents from the collection that match the given query filter.
|
static com.mongodb.client.result.DeleteResult |
deleteOne(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
org.bson.conversions.Bson filter,
com.mongodb.client.model.DeleteOptions options)
Removes at most one document from the collection that matches the given filter.
|
static com.mongodb.client.result.DeleteResult |
deleteOne(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
String filterQuery,
com.mongodb.client.model.DeleteOptions options)
Removes at most one document from the collection that matches the given filter.
|
static <T> io.toro.gloop.object.cursor.GloopCursor |
distinct(String connectionName,
String databaseName,
String collectionName,
String fieldName,
org.bson.conversions.Bson filter,
com.mongodb.client.ClientSession clientSession,
Class<T> resultClass,
boolean closeClient,
io.toro.gloop.engine.GloopExecutionContext context)
Gets the distinct values of the specified field name.
|
static <T> io.toro.gloop.object.cursor.GloopCursor |
distinct(String connectionName,
String databaseName,
String collectionName,
String fieldName,
String query,
com.mongodb.client.ClientSession clientSession,
Class<T> resultClass,
boolean closeClient,
io.toro.gloop.engine.GloopExecutionContext context)
Gets the distinct values of the specified field name.
|
static void |
drop(String connectionName,
String databaseName,
com.mongodb.client.ClientSession clientSession)
Drops this database.
|
static void |
drop(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession)
Drops this collection from the Database.
|
static void |
dropCollection(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession)
Drop a collection with the given name.
|
static void |
dropDatabase(String connectionName,
String databaseName)
Drops the database if it exists.
|
static void |
dropIndex(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
String indexName,
com.mongodb.client.model.DropIndexOptions dropIndexOptions)
Drops the index given its name.
|
static void |
dropIndexes(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
com.mongodb.client.model.DropIndexOptions dropIndexOptions)
Drop all the indexes on this collection, except for the default on _id.
|
static long |
estimatedDocumentCount(String connectionName,
String databaseName,
String collectionName,
long maxTime)
Gets an estimate of the count of documents in a collection using collection metadata.
|
static io.toro.gloop.object.property.GloopModel |
find(com.mongodb.client.MongoClient client,
String databaseName,
String collection,
String filter,
String projection,
com.mongodb.client.ClientSession clientSession,
boolean closeClient,
io.toro.gloop.engine.GloopExecutionContext context)
Open a Mongo Input cursor that will use the Gloop codec to convert records in MongoDB to Gloop Models
|
static io.toro.gloop.object.property.GloopModel |
find(String connectionName,
String databaseName,
String collection,
String filter,
String projection,
com.mongodb.client.ClientSession clientSession,
boolean closeClient,
io.toro.gloop.engine.GloopExecutionContext context)
Open a Mongo Input cursor that will use the Gloop codec to convert records in MongoDB to Gloop Models
|
static io.toro.gloop.object.property.GloopModel |
findFirst(com.mongodb.client.MongoClient client,
String databaseName,
String collection,
String filter,
String projection,
com.mongodb.client.ClientSession clientSession,
boolean closeClient,
io.toro.gloop.engine.GloopExecutionContext context)
Return a gloop model, which is the first result of the given query
|
static io.toro.gloop.object.property.GloopModel |
findFirst(String connectionName,
String databaseName,
String collection,
String filter,
String projection,
com.mongodb.client.ClientSession clientSession,
boolean closeClient,
io.toro.gloop.engine.GloopExecutionContext context)
Return a gloop model, which is the first result of the given query
|
static io.toro.gloop.object.property.GloopModel |
findOneAndDelete(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
org.bson.conversions.Bson filter,
com.mongodb.client.model.FindOneAndDeleteOptions options)
Atomically find a document and remove it.
|
static io.toro.gloop.object.property.GloopModel |
findOneAndDelete(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
String filter,
com.mongodb.client.model.FindOneAndDeleteOptions options)
Atomically find a document and remove it.
|
static io.toro.gloop.object.property.GloopModel |
findOneAndReplace(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
org.bson.conversions.Bson filter,
io.toro.gloop.object.property.GloopModel replacement,
com.mongodb.client.model.FindOneAndReplaceOptions options)
Atomically find a document and replace it.
|
static io.toro.gloop.object.property.GloopModel |
findOneAndReplace(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
String filter,
io.toro.gloop.object.property.GloopModel replacement,
com.mongodb.client.model.FindOneAndReplaceOptions options)
Atomically find a document and replace it.
|
static io.toro.gloop.object.property.GloopModel |
findOneAndUpdate(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
org.bson.conversions.Bson filter,
org.bson.conversions.Bson update,
com.mongodb.client.model.FindOneAndUpdateOptions options)
Atomically find a document and update it.
|
static io.toro.gloop.object.property.GloopModel |
findOneAndUpdate(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
String filter,
String update,
com.mongodb.client.model.FindOneAndUpdateOptions options)
Atomically find a document and update it.
|
static org.bson.Document |
fsync(String connectionName,
boolean async)
Forces the master server to fsync the RAM data to disk.
|
static org.bson.Document |
fsyncAndLock(String connectionName)
Forces the master server to fsync the RAM data to disk, then lock all writes.
|
static String |
getConnectPoint(String connectionName)
Gets a
String representation of current connection point, i.e. |
static org.bson.Document |
getCredentialsList(String connectionName)
Gets the list of credentials that this client authenticates all connections with
|
com.mongodb.client.MongoDatabase |
getDatabase(String connectionName,
String databaseName) |
static org.bson.codecs.configuration.CodecRegistry |
getDefaultCodecRegistry()
Gets the default codec registry.
|
static org.bson.codecs.configuration.CodecRegistry |
getGloopCodecRegistry()
Returns a codec registry which contains the Codec for Gloop Models.
|
static org.bson.Document |
getMongoClientOptions(String connectionName)
Gets the options that this client uses to connect to server.
|
static com.mongodb.TransactionOptions |
getTransactionOptions(com.mongodb.client.ClientSession clientSession)
Gets the transaction options.
|
static org.bson.Document |
getUsedDatabases(String connectionName)
Returns the list of databases used by the driver since this Mongo instance was created.
|
static boolean |
hasActiveTransaction(com.mongodb.client.ClientSession clientSession)
Returns true if there is an active transaction on this session, and false otherwise
|
static void |
insertMany(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
List<io.toro.gloop.object.property.GloopModel> documents,
boolean ordered,
Boolean bypassDocumentValidation)
Inserts one or more documents.
|
static io.toro.gloop.object.cursor.GloopCursor |
insertMany(String connectionName,
String databaseName,
String collection,
int batchSize,
com.mongodb.client.ClientSession clientSession,
boolean closeClient,
io.toro.gloop.engine.GloopExecutionContext context)
Open a Mongo Output cursor that will use the Gloop Codec to convert Gloop Models to Mongo DB documents, allowing
Gloop to write records.
|
static void |
insertOne(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
io.toro.gloop.object.property.GloopModel document,
Boolean bypassDocumentValidation)
Inserts the provided document.
|
static boolean |
isLocked(String connectionName)
Returns true if the database is locked (read-only), false otherwise.
|
static List<String> |
listCollectionNames(String connectionName,
String databaseName,
com.mongodb.client.ClientSession clientSession)
Gets the names of all the collections in this database.
|
static io.toro.gloop.object.property.GloopModel |
listCollections(String connectionName,
String databaseName,
com.mongodb.client.ClientSession clientSession)
Finds all the collections in this database.
|
static Collection<String> |
listDatabaseNames(String connectionName,
com.mongodb.client.ClientSession clientSession)
Get a list of the database names
|
static io.toro.gloop.object.property.GloopModel |
listDatabases(String connectionName,
com.mongodb.client.ClientSession clientSession)
Gets the list of databases
|
static io.toro.gloop.object.cursor.GloopCursor |
listIndexes(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
boolean closeClient,
io.toro.gloop.engine.GloopExecutionContext context)
Get all the indexes in this collection.
|
static <T> io.toro.gloop.object.cursor.GloopCursor |
mapReduce(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
Class<T> resultClass,
String mapFunction,
String reduceFunction,
boolean closeClient,
io.toro.gloop.engine.GloopExecutionContext context)
Aggregates documents according to the specified map-reduce function.
|
static void |
renameCollection(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
com.mongodb.MongoNamespace newCollectionNamespace,
boolean dropTarget)
Rename the collection with oldCollectionName to the newCollectionName.
|
static com.mongodb.client.result.UpdateResult |
replaceOne(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
org.bson.conversions.Bson filter,
io.toro.gloop.object.property.GloopModel replacement,
com.mongodb.client.model.ReplaceOptions options)
Replace a document in the collection according to the specified arguments.
|
static com.mongodb.client.result.UpdateResult |
replaceOne(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
String filterQuery,
io.toro.gloop.object.property.GloopModel replacement,
com.mongodb.client.model.ReplaceOptions options)
Replace a document in the collection according to the specified arguments.
|
static io.toro.gloop.object.property.GloopModel |
runCommand(String connectionName,
String databaseName,
com.mongodb.client.ClientSession clientSession,
org.bson.conversions.Bson command)
Executes the given command in the context of the current database with a read preference of
ReadPreference.primary() . |
static io.toro.gloop.object.property.GloopModel |
runCommand(String connectionName,
String databaseName,
com.mongodb.client.ClientSession clientSession,
String query)
Executes the given command in the context of the current database with a read preference of
ReadPreference.primary() . |
static com.mongodb.client.ClientSession |
startSession(String connectionName,
com.mongodb.ClientSessionOptions options)
Creates a client session.
|
static com.mongodb.client.ClientSession |
startSession(String connectionName,
io.toro.gloop.object.property.GloopModel clientSessionOptions)
Creates a client session.
|
static void |
startTransaction(com.mongodb.client.ClientSession clientSession,
io.toro.gloop.object.property.GloopModel transactionOptions)
Start a transaction in the context of this session with the given transaction options.
|
static void |
startTransaction(com.mongodb.client.ClientSession clientSession,
com.mongodb.TransactionOptions transactionOptions)
Start a transaction in the context of this session with the given transaction options.
|
static org.bson.Document |
unlock(String connectionName)
Unlocks the database, allowing the write operations to go through.
|
static com.mongodb.client.result.UpdateResult |
updateMany(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
org.bson.conversions.Bson filter,
org.bson.conversions.Bson update,
com.mongodb.client.model.UpdateOptions updateOptions)
Update all documents in the collection according to the specified arguments.
|
static com.mongodb.client.result.UpdateResult |
updateMany(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
String filter,
String update,
com.mongodb.client.model.UpdateOptions updateOptions)
Update all documents in the collection according to the specified arguments.
|
static com.mongodb.client.result.UpdateResult |
updateOne(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
org.bson.conversions.Bson filter,
org.bson.conversions.Bson update,
com.mongodb.client.model.UpdateOptions updateOptions)
Update a single document in the collection according to the specified arguments.
|
static com.mongodb.client.result.UpdateResult |
updateOne(String connectionName,
String databaseName,
String collectionName,
com.mongodb.client.ClientSession clientSession,
String filter,
String update,
com.mongodb.client.model.UpdateOptions updateOptions)
Update a single document in the collection according to the specified arguments.
|
static com.mongodb.client.ChangeStreamIterable<org.bson.Document> |
watch(String connectionName,
com.mongodb.client.ClientSession clientSession,
List<? extends org.bson.conversions.Bson> pipeline)
Creates a change stream for this client.
|
static void |
watch(String connectionName,
String databaseName,
com.mongodb.client.ClientSession clientSession,
List<? extends org.bson.conversions.Bson> pipeline,
String gloopService)
Creates a change stream for this database.
|
static com.mongodb.client.ChangeStreamIterable<org.bson.Document> |
watchWithQuery(String connectionName,
com.mongodb.client.ClientSession clientSession,
List<String> pipelineQueries)
Creates a change stream for this client.
|
@Autowired MongoDbMethods(io.toro.martini.database.DataSourceManager manager)
public static org.bson.codecs.configuration.CodecRegistry getGloopCodecRegistry()
import static org.bson.codecs.configuration.CodecRegistries.fromProviders; import static org.bson.codecs.configuration.CodecRegistries.fromRegistries; ... CodecRegistry pojoCodecRegistry = fromRegistries( MongoClient.getDefaultCodecRegistry(), MongoDbMethods.getGloopCodecRegistry(), // <-- added gloop codec here fromProviders( PojoCodecProvider.builder().automatic( true ).build() ) ); return new MongoClient( host, MongoClientOptions.builder().codecRegistry( pojoCodecRegistry ).build() );
@GloopObjectParameter(value="output{\n mongoFindCursor[]*{\n }\n}") public static io.toro.gloop.object.property.GloopModel find(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collection, String filter, String projection, com.mongodb.client.ClientSession clientSession, @GloopParameter(defaultValue="false") boolean closeClient, io.toro.gloop.engine.GloopExecutionContext context)
connectionName
- the name of the mongo db connectiondatabaseName
- the databaseName namecollection
- the collection namefilter
- selection filter using query operators.projection
- specifies the fields to return in the documents that match the query filterclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessioncloseClient
- boolean stating whether the cursor will close the mongoDb client after it has been exhaustedcontext
- the Gloop Execution Context@GloopObjectParameter(value="output{\n mongoFindCursor[]*{\n }\n}") public static io.toro.gloop.object.property.GloopModel find(@NotNull com.mongodb.client.MongoClient client, @NotNull String databaseName, @NotNull String collection, String filter, String projection, com.mongodb.client.ClientSession clientSession, @GloopParameter(defaultValue="false") boolean closeClient, io.toro.gloop.engine.GloopExecutionContext context)
client
- a pre-configured Mongo client, which must have the GloopCodec included. See here
.databaseName
- the databaseName namecollection
- the collection namefilter
- selection filter using query operators.projection
- specifies the fields to return in the documents that match the query filterclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessioncloseClient
- boolean stating whether the cursor will close the mongoDb client after it has been exhaustedcontext
- the Gloop Execution Context@GloopObjectParameter(value="output{\n mongoResult*{\n }\n}") public static io.toro.gloop.object.property.GloopModel findFirst(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collection, String filter, String projection, com.mongodb.client.ClientSession clientSession, @GloopParameter(defaultValue="false") boolean closeClient, io.toro.gloop.engine.GloopExecutionContext context)
connectionName
- the name of the mongo db connectiondatabaseName
- the databaseName namecollection
- the collection namefilter
- selection filter using query operators.projection
- specifies the fields to return in the documents that match the query filterclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessioncloseClient
- boolean stating whether the cursor will close the mongoDb client after it has been exhaustedcontext
- the Gloop Execution Context@GloopObjectParameter(value="output{\n mongoResult*{\n }\n}") public static io.toro.gloop.object.property.GloopModel findFirst(@NotNull com.mongodb.client.MongoClient client, @NotNull String databaseName, @NotNull String collection, String filter, String projection, com.mongodb.client.ClientSession clientSession, @GloopParameter(defaultValue="false") boolean closeClient, io.toro.gloop.engine.GloopExecutionContext context)
client
- a pre-configured Mongo client, which must have the GloopCodec included. See here
.databaseName
- the databaseName namecollection
- the collection namefilter
- selection filter using query operators.projection
- specifies the fields to return in the documents that match the query filterclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessioncloseClient
- boolean stating whether the cursor will close the mongoDb client after it has been exhaustedcontext
- the Gloop Execution Context@GloopObjectParameter(value="output{\n mongoInsertCursor[]*{\n }\n}") public static io.toro.gloop.object.cursor.GloopCursor insertMany(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collection, @GloopParameter(defaultValue="10000") int batchSize, com.mongodb.client.ClientSession clientSession, @GloopParameter(defaultValue="false") boolean closeClient, io.toro.gloop.engine.GloopExecutionContext context)
connectionName
- the name of the connectiondatabaseName
- the databaseName namecollection
- the collection nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessioncloseClient
- boolean stating whether the cursor will close the mongoDb client after it has been exhaustedcontext
- the Gloop Execution Contextpublic static void insertMany(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @NotNull List<io.toro.gloop.object.property.GloopModel> documents, @GloopParameter(defaultValue="false") boolean ordered, Boolean bypassDocumentValidation)
bulkWrite
method
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessiondocuments
- the documents to insertcom.mongodb.DuplicateKeyException
- if the write failed to a duplicate unique keycom.mongodb.WriteConcernException
- if the write failed due being unable to fulfil the write concerncom.mongodb.MongoException
- if the write failed due some other failurepublic static org.bson.Document getUsedDatabases(@NotNull String connectionName)
connectionName
- the name of the mongo db connectionpublic static void dropDatabase(@NotNull String connectionName, @NotNull String databaseName)
connectionName
- the name of the mongo db connectiondatabaseName
- name of database to dropcom.mongodb.MongoException
- if the operation failspublic static org.bson.Document fsync(@NotNull String connectionName, @GloopParameter(defaultValue="false") boolean async)
connectionName
- the name of the mongo db connectionasync
- if true, the fsync will be done asynchronously on the server.com.mongodb.MongoException
- if there's a failurepublic static org.bson.Document fsyncAndLock(@NotNull String connectionName)
connectionName
- the name of the mongo db connectioncom.mongodb.MongoException
- if there's a failurepublic static org.bson.Document unlock(@NotNull String connectionName)
connectionName
- the name of the mongo db connectionDBObject
in the following form {"ok": 1,"info": "unlock completed"}
com.mongodb.MongoException
- if there's a failurepublic static boolean isLocked(@NotNull String connectionName)
connectionName
- the name of the mongo db connectioncom.mongodb.MongoException
- if the operation failspublic String connectionToString(@NotNull String connectionName)
connectionName
- the name of the mongo db connectioncom.mongodb.MongoException
- if the operation failspublic static MongoDbDataSource connection(String connectionName)
connectionName
- the name of the saved database connection in Martini@Nullable public static String getConnectPoint(@NotNull String connectionName)
String
representation of current connection point, i.e. master.connectionName
- the name of the mongo db connectionpublic static org.bson.codecs.configuration.CodecRegistry getDefaultCodecRegistry()
ValueCodecProvider
BsonValueCodecProvider
DBRefCodecProvider
DBObjectCodecProvider
DocumentCodecProvider
IterableCodecProvider
MapCodecProvider
GeoJsonCodecProvider
GridFSFileCodecProvider
Jsr310CodecProvider
MongoClientOptions.getCodecRegistry()
public static org.bson.Document getMongoClientOptions(@NotNull String connectionName)
connectionName
- the name of the mongo db connection
Note: MongoClientOptions
is immutable.
public static org.bson.Document getCredentialsList(@NotNull String connectionName)
connectionName
- the name of the mongo db connectionpublic static com.mongodb.client.ClientSession startSession(@NotNull String connectionName, com.mongodb.ClientSessionOptions options)
Note: A ClientSession instance can not be used concurrently in multiple operations.
connectionName
- the name of the mongo db connectionoptions
- the options for the client session. If null, default options will be used@GloopParameter(name="$clientSession") public static com.mongodb.client.ClientSession startSession(@NotNull String connectionName, @GloopObjectParameter(value="clientSessionOptions#io.toro.martini.mongodb.ClientSessionOptions{\n}\n") io.toro.gloop.object.property.GloopModel clientSessionOptions)
Note: A ClientSession instance can not be used concurrently in multiple operations.
connectionName
- the name of the mongo db connectionclientSessionOptions
- the options for the client session. If null, default options will be usedpublic static void startTransaction(@NotNull com.mongodb.client.ClientSession clientSession, com.mongodb.TransactionOptions transactionOptions)
clientSession
- the client sessiontransactionOptions
- the options to apply to the transactionpublic static void startTransaction(@NotNull com.mongodb.client.ClientSession clientSession, @GloopObjectParameter(value="transactionOptions#io.toro.martini.mongodb.TransactionOptions{\n}\n") io.toro.gloop.object.property.GloopModel transactionOptions)
clientSession
- the client sessiontransactionOptions
- the options to apply to the transactionpublic static boolean hasActiveTransaction(@NotNull com.mongodb.client.ClientSession clientSession)
clientSession
- the client sessionpublic static com.mongodb.TransactionOptions getTransactionOptions(@NotNull com.mongodb.client.ClientSession clientSession)
clientSession
- the client session*public static void commitTransaction(@NotNull com.mongodb.client.ClientSession clientSession)
clientSession
- the client session*public static void abortTransaction(@NotNull com.mongodb.client.ClientSession clientSession)
clientSession
- the client sessionpublic static Collection<String> listDatabaseNames(@NotNull String connectionName, com.mongodb.client.ClientSession clientSession)
connectionName
- the name of the mongo db connectionclientSession
- the client session with which to associate this operation. Leave as null if there is no
session@GloopObjectParameter(value="output{\n mongoDbDatabases#io.toro.martini.mongodb.Database[]{\n }\n}") public static io.toro.gloop.object.property.GloopModel listDatabases(@NotNull String connectionName, com.mongodb.client.ClientSession clientSession)
connectionName
- the name of the mongo db connectionclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionpublic com.mongodb.client.MongoDatabase getDatabase(@NotNull String connectionName, @NotNull String databaseName)
connectionName
- the name of the mongo db connectiondatabaseName
- the name of the database to retrieveMongoDatabase
representing the specified databaseIllegalArgumentException
- if databaseName is invalidMongoNamespace.checkDatabaseNameValidity(String)
public static io.toro.gloop.object.property.GloopModel runCommand(@NotNull String connectionName, @NotNull String databaseName, com.mongodb.client.ClientSession clientSession, @NotNull org.bson.conversions.Bson command)
ReadPreference.primary()
.connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessioncommand
- the command to be runpublic static io.toro.gloop.object.property.GloopModel runCommand(@NotNull String connectionName, @NotNull String databaseName, com.mongodb.client.ClientSession clientSession, @NotNull String query)
ReadPreference.primary()
.connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionquery
- the command to be runpublic static void drop(@NotNull String connectionName, @NotNull String databaseName, com.mongodb.client.ClientSession clientSession)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionpublic static void drop(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionpublic static List<String> listCollectionNames(@NotNull String connectionName, @NotNull String databaseName, com.mongodb.client.ClientSession clientSession)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
session@GloopObjectParameter(value="output{\n mongoDbCollections#io.toro.martini.mongodb.Collection[]{\n }\n}") public static io.toro.gloop.object.property.GloopModel listCollections(@NotNull String connectionName, @NotNull String databaseName, com.mongodb.client.ClientSession clientSession)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionpublic static void createDatabaseAndCollection(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession)
connectionName
- the name of the mongo db connectiondatabaseName
- the database name, will be created if it doesn't already existcollectionName
- the name for the new collection to createclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionpublic static void dropCollection(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession)
connectionName
- the name of the mongo db connectiondatabaseName
- the database namecollectionName
- the name for the collection to dropclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionpublic static void createView(@NotNull String connectionName, @NotNull String databaseName, @NotNull String viewName, String viewOn, List<? extends org.bson.conversions.Bson> pipeline, com.mongodb.client.ClientSession clientSession, com.mongodb.client.model.CreateViewOptions createViewOptions)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameviewName
- the name of the view to createviewOn
- the backing collection/view for the viewpipeline
- the pipeline that defines the viewclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessioncreateViewOptions
- create view optionspublic static long countDocuments(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, org.bson.conversions.Bson filter)
Note: When migrating from count()
to countDocuments()
the following query operators must be
replaced:
+-------------+--------------------------------+ | Operator | Replacement | +=============+================================+ | $where | $expr | +-------------+--------------------------------+ | $near | $geoWithin with $center | +-------------+--------------------------------+ | $nearSphere | $geoWithin with $centerSphere | +-------------+--------------------------------+
connectionName
- the name of the mongo db connectiondatabaseName
- the database namecollectionName
- the collection nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- the query filterpublic static long countDocuments(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, String query, com.mongodb.client.ClientSession clientSession)
query
- leave null to count all documents in the collection
Note: When migrating from count()
to countDocuments()
the following query operators
must be
replaced:
+-------------+--------------------------------+ | Operator | Replacement | +=============+================================+ | $where | $expr | +-------------+--------------------------------+ | $near | $geoWithin with $center | +-------------+--------------------------------+ | $nearSphere | $geoWithin with $centerSphere | +-------------+--------------------------------+
connectionName
- the name of the mongo db connectiondatabaseName
- the database namecollectionName
- the collection nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionpublic static long estimatedDocumentCount(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, @NotNull long maxTime)
connectionName
- the name of the mongo db connectiondatabaseName
- the database namecollectionName
- the collection namemaxTime
- The maximum time to wait in milliseconds. Set to a number <= 0 for no time limit.@GloopObjectParameter(value="mongoDbDistinctValuesCursor[]:object") public static <T> io.toro.gloop.object.cursor.GloopCursor distinct(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, @NotNull String fieldName, org.bson.conversions.Bson filter, com.mongodb.client.ClientSession clientSession, @NotNull Class<T> resultClass, @GloopParameter(defaultValue="false") boolean closeClient, io.toro.gloop.engine.GloopExecutionContext context)
connectionName
- the name of the mongo db connectiondatabaseName
- the database namecollectionName
- the collection namefieldName
- the field nameresultClass
- the class to cast any distinct items into.filter
- the filterclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessioncloseClient
- boolean stating whether the cursor will close the mongoDb client after it has been
exhausted@GloopObjectParameter(value="distinctValuesCursor[]:object") public static <T> io.toro.gloop.object.cursor.GloopCursor distinct(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, @NotNull String fieldName, @NotNull String query, com.mongodb.client.ClientSession clientSession, Class<T> resultClass, @GloopParameter(defaultValue="false") boolean closeClient, io.toro.gloop.engine.GloopExecutionContext context)
connectionName
- the name of the mongo db connectiondatabaseName
- the database namecollectionName
- the collection namefieldName
- the field namequery
- the queryclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionresultClass
- the class to cast any distinct items into.closeClient
- boolean stating whether the cursor will close the mongoDb client after it has been
exhausted@GloopObjectParameter(value="mongoAggregateCursor[]:object") public static io.toro.gloop.object.cursor.GloopCursor aggregate(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, List<? extends org.bson.conversions.Bson> pipeline, com.mongodb.client.ClientSession clientSession, @GloopParameter(defaultValue="false") boolean closeClient, io.toro.gloop.engine.GloopExecutionContext context)
connectionName
- the name of the mongo db connectiondatabaseName
- the database namecollectionName
- the collection namepipeline
- the aggregation pipelineclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessioncloseClient
- boolean stating whether the cursor will close the mongoDb client after it has been
exhausted@GloopObjectParameter(value="mongoAggregateCursor[]:object") public static io.toro.gloop.object.cursor.GloopCursor aggregateWithQuery(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, @NotNull List<String> pipelineQueries, com.mongodb.client.ClientSession clientSession, @GloopParameter(defaultValue="false") boolean closeClient, io.toro.gloop.engine.GloopExecutionContext context)
connectionName
- the name of the mongo db connectiondatabaseName
- the database namecollectionName
- the collection namepipelineQueries
- the aggregation pipeline queriesclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessioncloseClient
- boolean stating whether the cursor will close the mongoDb client after it has been
exhaustedpublic static com.mongodb.client.ChangeStreamIterable<org.bson.Document> watch(@NotNull String connectionName, com.mongodb.client.ClientSession clientSession, List<? extends org.bson.conversions.Bson> pipeline)
connectionName
- the name of the mongo db connectionclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionpipeline
- the aggregation pipeline to apply to the change stream. Leave as null if there are no queries@GloopObjectParameter(value="output{\n mongoAggregateCursor[]*{\n }\n}") public static void watch(@NotNull String connectionName, @NotNull String databaseName, com.mongodb.client.ClientSession clientSession, List<? extends org.bson.conversions.Bson> pipeline, @NotNull String gloopService)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionpipeline
- the aggregation pipeline to apply to the change streamgloopService
- The gloop service to invoke when a change is madepublic static com.mongodb.client.ChangeStreamIterable<org.bson.Document> watchWithQuery(@NotNull String connectionName, com.mongodb.client.ClientSession clientSession, List<String> pipelineQueries)
connectionName
- the name of the mongo db connectionclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionpipelineQueries
- the aggregation pipeline queries to apply to the change stream. Leave as null if
there are
no queries@GloopObjectParameter(value="mongoDbMapReduceCursor[]:object") public static <T> io.toro.gloop.object.cursor.GloopCursor mapReduce(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, Class<T> resultClass, @NotNull String mapFunction, @NotNull String reduceFunction, @GloopParameter(defaultValue="false") boolean closeClient, io.toro.gloop.engine.GloopExecutionContext context)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionmapFunction
- A JavaScript function that associates or "maps" a value with a key and emits the key
and value
pair.reduceFunction
- A JavaScript function that "reduces" to a single object all the values associated
with acloseClient
- boolean stating whether the cursor will close the mongoDb client after it has been
exhausted
particular key.@GloopObjectParameter(value="mongoDbBulkWriteCursor[]:object:::::com.mongodb.client.model.WriteModel") public static io.toro.gloop.object.cursor.GloopCursor bulkWrite(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @GloopParameter(defaultValue="10000") int batchSize, @GloopParameter(defaultValue="false") boolean closeClient, @GloopParameter(defaultValue="false") boolean ordered, Boolean bypassDocumentValidation, io.toro.gloop.engine.GloopExecutionContext context)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is
enabled. The eligibility for retryable write support for bulk operations is determined on the whole bulk
write.
If the requests
contain any UpdateManyModels
or DeleteManyModels
then the bulk
operation
will not support retryable writes.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionbatchSize
- how many write models to cache before sending them to mongo dbcloseClient
- a boolean stating whether to close the client once the cursor has been closedpublic static void insertOne(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @NotNull io.toro.gloop.object.property.GloopModel document, Boolean bypassDocumentValidation)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessiondocument
- the document to insertcom.mongodb.MongoWriteException
- if the write failed due some other failure specific to the insert
commandcom.mongodb.MongoWriteConcernException
- if the write failed due being unable to fulfil the write concerncom.mongodb.MongoCommandException
- if the write failed due to document validation reasonscom.mongodb.MongoException
- if the write failed due some other failurepublic static com.mongodb.client.result.DeleteResult deleteOne(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, org.bson.conversions.Bson filter, com.mongodb.client.model.DeleteOptions options)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- 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 failurepublic static com.mongodb.client.result.DeleteResult deleteOne(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, String filterQuery, com.mongodb.client.model.DeleteOptions options)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilterQuery
- 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 failurepublic static com.mongodb.client.result.DeleteResult deleteMany(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, org.bson.conversions.Bson filter, com.mongodb.client.model.DeleteOptions options)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- 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 failurepublic static com.mongodb.client.result.DeleteResult deleteMany(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, String filterQuery, com.mongodb.client.model.DeleteOptions options)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilterQuery
- 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 failurepublic static com.mongodb.client.result.UpdateResult replaceOne(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, org.bson.conversions.Bson filter, io.toro.gloop.object.property.GloopModel replacement, com.mongodb.client.model.ReplaceOptions options)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- the query filter to apply the 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 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 failurepublic static com.mongodb.client.result.UpdateResult replaceOne(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, String filterQuery, io.toro.gloop.object.property.GloopModel replacement, com.mongodb.client.model.ReplaceOptions options)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilterQuery
- the query filter to apply the 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 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 failurepublic static com.mongodb.client.result.UpdateResult updateOne(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @NotNull org.bson.conversions.Bson filter, @NotNull org.bson.conversions.Bson update, com.mongodb.client.model.UpdateOptions updateOptions)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- 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 updateOptions 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 failurepublic static com.mongodb.client.result.UpdateResult updateOne(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @NotNull String filter, @NotNull String update, com.mongodb.client.model.UpdateOptions updateOptions)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- 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 updateOptions 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 failurepublic static com.mongodb.client.result.UpdateResult updateMany(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, org.bson.conversions.Bson filter, org.bson.conversions.Bson update, com.mongodb.client.model.UpdateOptions updateOptions)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- 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 failurepublic static com.mongodb.client.result.UpdateResult updateMany(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, String filter, String update, com.mongodb.client.model.UpdateOptions updateOptions)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- 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@Nullable public static io.toro.gloop.object.property.GloopModel findOneAndDelete(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @NotNull org.bson.conversions.Bson filter, com.mongodb.client.model.FindOneAndDeleteOptions options)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- the query filter to find the document withoptions
- the options to apply to the operation@Nullable public static io.toro.gloop.object.property.GloopModel findOneAndDelete(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @NotNull String filter, com.mongodb.client.model.FindOneAndDeleteOptions options)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- the query filter to find the document withoptions
- the options to apply to the operation@Nullable public static io.toro.gloop.object.property.GloopModel findOneAndReplace(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, org.bson.conversions.Bson filter, io.toro.gloop.object.property.GloopModel replacement, com.mongodb.client.model.FindOneAndReplaceOptions options)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- 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 io.toro.gloop.object.property.GloopModel findOneAndReplace(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, String filter, io.toro.gloop.object.property.GloopModel replacement, com.mongodb.client.model.FindOneAndReplaceOptions options)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- 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 io.toro.gloop.object.property.GloopModel findOneAndUpdate(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @NotNull org.bson.conversions.Bson filter, @NotNull org.bson.conversions.Bson update, com.mongodb.client.model.FindOneAndUpdateOptions options)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- 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@Nullable public static io.toro.gloop.object.property.GloopModel findOneAndUpdate(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @NotNull String filter, @NotNull String update, com.mongodb.client.model.FindOneAndUpdateOptions options)
Note: Supports retryable writes on MongoDB server versions 3.6 or higher when the retryWrites setting is enabled.
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionfilter
- 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 returnedpublic static String createIndex(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @NotNull org.bson.conversions.Bson keys, com.mongodb.client.model.IndexOptions indexOptions)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionkeys
- an object describing the index key(s), which may not be null.indexOptions
- the options for the indexpublic static String createIndex(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @NotNull String keys, com.mongodb.client.model.IndexOptions indexOptions)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionkeys
- an object describing the index key(s), which may not be null.indexOptions
- the options for the indexpublic static List<String> createIndexes(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, List<com.mongodb.client.model.IndexModel> indexes, com.mongodb.client.model.CreateIndexOptions createIndexOptions)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionindexes
- the list of indexescreateIndexOptions
- options to use when creating indexespublic static io.toro.gloop.object.cursor.GloopCursor listIndexes(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @GloopParameter(defaultValue="false") boolean closeClient, io.toro.gloop.engine.GloopExecutionContext context)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionpublic static void dropIndex(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, @NotNull String indexName, com.mongodb.client.model.DropIndexOptions dropIndexOptions)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionindexName
- the name of the index to removedropIndexOptions
- the options to use when dropping indexespublic static void dropIndexes(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, com.mongodb.client.model.DropIndexOptions dropIndexOptions)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessiondropIndexOptions
- the options to use when dropping indexespublic static void renameCollection(@NotNull String connectionName, @NotNull String databaseName, @NotNull String collectionName, com.mongodb.client.ClientSession clientSession, com.mongodb.MongoNamespace newCollectionNamespace, @GloopParameter(defaultValue="false") boolean dropTarget)
connectionName
- the name of the mongo db connectiondatabaseName
- the database nameclientSession
- the client session with which to associate this operation. Leave as null if there is no
sessionnewCollectionNamespace
- the name the collection will be renamed todropTarget
- if mongod should drop the target of renameCollection prior to renaming the collection.com.mongodb.MongoServerException
- if you provide a newCollectionName that is the name of an existing
collection and dropTarget is false, or if the oldCollectionName is the name of a collection that doesn't
existCopyright © 2020. All rights reserved.