Package org.restheart.mongodb.db
Class Databases
java.lang.Object
org.restheart.mongodb.db.Databases
- Author:
- Andrea Di Cesare <andrea@softinstigate.com>
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncom.mongodb.client.MongoCollection<org.bson.BsonDocument>collection(Optional<RSOps> rsOps, String dbName, String collName) voidcreateIndex(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, org.bson.BsonDocument keys, Optional<org.bson.BsonDocument> options) deleteCollection(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, org.bson.BsonObjectId requestEtag, boolean checkEtag) deleteDatabase(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, org.bson.BsonObjectId requestEtag, boolean checkEtag) intdeleteIndex(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collection, String indexId) booleandoesDbExist(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName) Returns true if the collection existscom.mongodb.client.FindIterable<org.bson.BsonDocument>findIterable(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, org.bson.BsonDocument sortBy, org.bson.BsonDocument filters, org.bson.BsonDocument hint, org.bson.BsonDocument keys, int batchSize) static Databasesget()org.bson.BsonArraygetCollectionData(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, int page, int pagesize, org.bson.BsonDocument sortBy, org.bson.BsonDocument filters, org.bson.BsonDocument hint, org.bson.BsonDocument keys, boolean useCache) List<org.bson.BsonDocument>getCollectionIndexes(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collectionName) getCollectionNames(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName) org.bson.BsonDocumentgetCollectionProperties(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName) longgetCollectionSize(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, org.bson.BsonDocument filter) Returns the number of documents in the given collection (taking into account the filters in case).org.bson.BsonArraygetDatabaseData(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, List<String> colls, int page, int pagesize, boolean noCache) getDatabaseNames(Optional<com.mongodb.client.ClientSession> cs) org.bson.BsonDocumentgetDatabaseProperties(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName) longupsertCollection(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, ExchangeKeys.METHOD method, boolean updating, org.bson.BsonDocument content, String requestEtag, boolean checkEtag) upsertDB(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, ExchangeKeys.METHOD method, boolean updating, org.bson.BsonDocument newContent, String requestEtag, boolean checkEtag)
-
Field Details
-
PROPS_QUERY
public static final org.bson.conversions.Bson PROPS_QUERY
-
-
Method Details
-
get
-
doesDbExist
public boolean doesDbExist(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName) Returns true if the collection exists- Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the name of the db- Returns:
- true if the db exists
-
getCollectionNames
public List<String> getCollectionNames(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName) - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database name- Returns:
- A ordered List of collection names
-
getDBSize
- Parameters:
colls- the collections list got from getCollectionNames()- Returns:
- the number of collections in this db
-
getDatabaseProperties
public org.bson.BsonDocument getDatabaseProperties(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName) - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database name- Returns:
- the db props
-
getDatabaseData
public org.bson.BsonArray getDatabaseData(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, List<String> colls, int page, int pagesize, boolean noCache) throws IllegalQueryParamenterException - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database namecolls- the collections list as got from getCollectionNames()page-pagesize-noCache-- Returns:
- the db data
- Throws:
IllegalQueryParamenterException
-
upsertDB
public OperationResult upsertDB(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, ExchangeKeys.METHOD method, boolean updating, org.bson.BsonDocument newContent, String requestEtag, boolean checkEtag) - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database namemethod-updating-newContent-requestEtag-- Returns:
- the OperationResult
-
deleteDatabase
public OperationResult deleteDatabase(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, org.bson.BsonObjectId requestEtag, boolean checkEtag) - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database namerequestEtag-checkEtag-- Returns:
- the OperationResult
-
getDatabaseNames
- Parameters:
cs- the client session- Returns:
- and ordered list of the databases
-
getCollectionProperties
public org.bson.BsonDocument getCollectionProperties(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName) - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database namecollName-- Returns:
- the collection properties
-
collection
public com.mongodb.client.MongoCollection<org.bson.BsonDocument> collection(Optional<RSOps> rsOps, String dbName, String collName) - Parameters:
rsOps- the ReplicaSet connection optionsdbName- the database namecollName-- Returns:
- the MongoCollection
-
getCollectionSize
public long getCollectionSize(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, org.bson.BsonDocument filter) Returns the number of documents in the given collection (taking into account the filters in case).- Parameters:
cs- the ClientSessionrsOps- the ReplicaSet connection optionsdbName- the database namecollName- the collection namefilters- the filters to apply. it is a Deque collection of mongodb query conditions.- Returns:
- the number of documents in the given collection (taking into account the filters in case)
-
getCollectionData
public org.bson.BsonArray getCollectionData(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, int page, int pagesize, org.bson.BsonDocument sortBy, org.bson.BsonDocument filters, org.bson.BsonDocument hint, org.bson.BsonDocument keys, boolean useCache) throws org.bson.json.JsonParseException - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database namecollName- the collection namepage-pagesize-sortBy-filter-hint-keys-useCache-- Returns:
- the documents in the collection as a BsonArray
- Throws:
org.bson.json.JsonParseException
-
deleteCollection
public OperationResult deleteCollection(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, org.bson.BsonObjectId requestEtag, boolean checkEtag) - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database namecollName- the collection namerequestEtag-checkEtag-- Returns:
- the OperationResult
-
upsertCollection
public OperationResult upsertCollection(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, ExchangeKeys.METHOD method, boolean updating, org.bson.BsonDocument content, String requestEtag, boolean checkEtag) - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database namemethod- the request methodupdating- true if updating, false if creatingcollName-content-requestEtag-checkEtag-- Returns:
- the OperationResult
-
deleteIndex
public int deleteIndex(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collection, String indexId) - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database namecollection-indexId-- Returns:
- the HTTP status code
-
getCollectionIndexes
public List<org.bson.BsonDocument> getCollectionIndexes(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collectionName) - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database namecollectionName-- Returns:
- an ordered list of the indexes
-
findIterable
public com.mongodb.client.FindIterable<org.bson.BsonDocument> findIterable(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, org.bson.BsonDocument sortBy, org.bson.BsonDocument filters, org.bson.BsonDocument hint, org.bson.BsonDocument keys, int batchSize) - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database namecollName- the collection namesortBy-filters-hint-keys-batchSize-- Returns:
- the FindIterable
-
createIndex
public void createIndex(Optional<com.mongodb.client.ClientSession> cs, Optional<RSOps> rsOps, String dbName, String collName, org.bson.BsonDocument keys, Optional<org.bson.BsonDocument> options) - Parameters:
cs- the client sessionrsOps- the ReplicaSet connection optionsdbName- the database namecollName- the collection namekeys-options-
-