Package org.restheart.mongodb.db
Interface Database
- All Known Implementing Classes:
DatabaseImpl
public interface Database
- Author:
- Maurizio Turatti <maurizio@softinstigate.com>
-
Method Summary
Modifier and TypeMethodDescriptionvoidcreateIndex(com.mongodb.client.ClientSession cs, String dbName, String collection, org.bson.BsonDocument keys, org.bson.BsonDocument options)deleteCollection(com.mongodb.client.ClientSession cs, String dbName, String collectionName, org.bson.BsonObjectId requestEtag, boolean checkEtag)deleteDatabase(com.mongodb.client.ClientSession cs, String dbName, org.bson.BsonObjectId requestEtag, boolean checkEtag)intdeleteIndex(com.mongodb.client.ClientSession cs, String dbName, String collection, String indexId)booleandoesCollectionExist(com.mongodb.client.ClientSession cs, String dbName, String collName)booleandoesDbExist(com.mongodb.client.ClientSession cs, String dbName)com.mongodb.client.MongoCollection<org.bson.BsonDocument>getCollection(String dbName, String collectionName)org.bson.BsonArraygetCollectionData(com.mongodb.client.ClientSession cs, com.mongodb.client.MongoCollection<org.bson.BsonDocument> collection, int page, int pagesize, org.bson.BsonDocument sortBy, org.bson.BsonDocument filter, org.bson.BsonDocument hint, org.bson.BsonDocument keys, ExchangeKeys.EAGER_CURSOR_ALLOCATION_POLICY cursorAllocationPolicy)List<org.bson.BsonDocument>getCollectionIndexes(com.mongodb.client.ClientSession cs, String dbName, String collectionName)getCollectionNames(com.mongodb.client.ClientSession cs, String dbName)org.bson.BsonDocumentgetCollectionProperties(com.mongodb.client.ClientSession cs, String dbName, String collectionName)longgetCollectionSize(com.mongodb.client.ClientSession cs, com.mongodb.client.MongoCollection<org.bson.BsonDocument> collection, org.bson.BsonDocument filters)com.mongodb.client.MongoDatabasegetDatabase(String dbName)org.bson.BsonArraygetDatabaseData(com.mongodb.client.ClientSession cs, String dbName, List<String> collections, int page, int pagesize, boolean noCache)getDatabaseNames(com.mongodb.client.ClientSession cs)org.bson.BsonDocumentgetDatabaseProperties(com.mongodb.client.ClientSession cs, String dbName)longcom.mongodb.client.FindIterable<org.bson.BsonDocument>getFindIterable(com.mongodb.client.ClientSession cs, com.mongodb.client.MongoCollection<org.bson.BsonDocument> collection, org.bson.BsonDocument sortBy, org.bson.BsonDocument filters, org.bson.BsonDocument hint, org.bson.BsonDocument keys)Returs the FindIterable of the collection applying sorting, filtering and projection.upsertCollection(com.mongodb.client.ClientSession cs, String dbName, String collectionName, org.bson.BsonDocument content, String requestEtag, boolean updating, boolean patching, boolean checkEtag)upsertDB(com.mongodb.client.ClientSession cs, String dbName, org.bson.BsonDocument content, String requestEtag, boolean updating, boolean patching, boolean checkEtag)
-
Method Details
-
deleteCollection
OperationResult deleteCollection(com.mongodb.client.ClientSession cs, String dbName, String collectionName, org.bson.BsonObjectId requestEtag, boolean checkEtag)- Parameters:
cs- the client sessiondbName-collectionName-requestEtag-checkEtag-- Returns:
- HTTP status code
-
deleteDatabase
OperationResult deleteDatabase(com.mongodb.client.ClientSession cs, String dbName, org.bson.BsonObjectId requestEtag, boolean checkEtag)- Parameters:
cs- the client sessiondbName-requestEtag-checkEtag-- Returns:
- HTTP status code
-
doesDbExist
- Parameters:
cs-dbName-- Returns:
- true if DB dbName exists
-
doesCollectionExist
- Parameters:
cs- the client sessiondbName-collName-- Returns:
- true if exists the collection collName exists in DB dbName
-
getCollection
com.mongodb.client.MongoCollection<org.bson.BsonDocument> getCollection(String dbName, String collectionName)- Parameters:
dbName-collectionName-- Returns:
- A Collection
-
getCollectionData
org.bson.BsonArray getCollectionData(com.mongodb.client.ClientSession cs, com.mongodb.client.MongoCollection<org.bson.BsonDocument> collection, int page, int pagesize, org.bson.BsonDocument sortBy, org.bson.BsonDocument filter, org.bson.BsonDocument hint, org.bson.BsonDocument keys, ExchangeKeys.EAGER_CURSOR_ALLOCATION_POLICY cursorAllocationPolicy)- Parameters:
cs- the client sessioncollection-page-pagesize-sortBy-filter-hint-keys-cursorAllocationPolicy-- Returns:
- Collection Data as ArrayList of BsonDocument
-
getCollectionProperties
org.bson.BsonDocument getCollectionProperties(com.mongodb.client.ClientSession cs, String dbName, String collectionName)- Parameters:
cs- the client sessiondbName-collectionName-- Returns:
- Collection properties
-
getCollectionSize
long getCollectionSize(com.mongodb.client.ClientSession cs, com.mongodb.client.MongoCollection<org.bson.BsonDocument> collection, org.bson.BsonDocument filters)- Parameters:
cs- the client sessioncollection-filters-- Returns:
- the number of documents in the given collection (taking into account the filters in case)
-
getDatabase
- Parameters:
dbName-- Returns:
- the MongoDatabase
-
getDBSize
- Parameters:
collections- the collection names- Returns:
- the number of collections in this db
-
getDatabaseData
org.bson.BsonArray getDatabaseData(com.mongodb.client.ClientSession cs, String dbName, List<String> collections, int page, int pagesize, boolean noCache) throws IllegalQueryParamenterException- Parameters:
cs- the client sessiondbName-collections- the collections list as got from getCollectionNames()page-pagesize-noCache- true to avoid using caching- Returns:
- the db data
- Throws:
IllegalQueryParamenterException
-
getDatabaseNames
- Parameters:
cs- the client session- Returns:
- A List of database names
-
getCollectionNames
- Parameters:
cs- the client sessiondbName-- Returns:
- A List of collection names
-
getDatabaseProperties
- Parameters:
cs-dbName-- Returns:
- the db props
-
upsertCollection
OperationResult upsertCollection(com.mongodb.client.ClientSession cs, String dbName, String collectionName, org.bson.BsonDocument content, String requestEtag, boolean updating, boolean patching, boolean checkEtag)- Parameters:
cs- the client sessiondbName-collectionName-content-requestEtag-updating-patching-checkEtag-- Returns:
-
upsertDB
OperationResult upsertDB(com.mongodb.client.ClientSession cs, String dbName, org.bson.BsonDocument content, String requestEtag, boolean updating, boolean patching, boolean checkEtag)- Parameters:
cs- the client sessiondbName-content-requestEtag-updating-patching-checkEtag-- Returns:
-
deleteIndex
int deleteIndex(com.mongodb.client.ClientSession cs, String dbName, String collection, String indexId)- Parameters:
cs- the client sessiondbName-collection-indexId-- Returns:
- the operation result
-
getCollectionIndexes
List<org.bson.BsonDocument> getCollectionIndexes(com.mongodb.client.ClientSession cs, String dbName, String collectionName)- Parameters:
cs- the client sessiondbName-collectionName-- Returns:
- A List of indexes for collectionName in dbName
-
createIndex
void createIndex(com.mongodb.client.ClientSession cs, String dbName, String collection, org.bson.BsonDocument keys, org.bson.BsonDocument options)- Parameters:
cs- the client sessiondbName-collection-keys-options-
-
getFindIterable
com.mongodb.client.FindIterable<org.bson.BsonDocument> getFindIterable(com.mongodb.client.ClientSession cs, com.mongodb.client.MongoCollection<org.bson.BsonDocument> collection, org.bson.BsonDocument sortBy, org.bson.BsonDocument filters, org.bson.BsonDocument hint, org.bson.BsonDocument keys) throws org.bson.json.JsonParseExceptionReturs the FindIterable of the collection applying sorting, filtering and projection.- Parameters:
cs- the client sessioncollection- the mongodb MongoCollection<BsonDocument> objectsortBy- the Deque collection of fields to use for sorting (prepend field name with - for descending sorting)filters- the filters to apply. it is a Deque collection of mongodb query conditions.hint- the index hint to apply.keys-- Returns:
- Throws:
org.bson.json.JsonParseException
-