Package org.restheart.mongodb.db
Class DatabaseImpl
- java.lang.Object
-
- org.restheart.mongodb.db.DatabaseImpl
-
-
Field Summary
Fields Modifier and Type Field Description static org.bson.conversions.BsonPROPS_QUERY
-
Constructor Summary
Constructors Constructor Description DatabaseImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateIndex(com.mongodb.client.ClientSession cs, String dbName, String collection, org.bson.BsonDocument keys, org.bson.BsonDocument options)OperationResultdeleteCollection(com.mongodb.client.ClientSession cs, String dbName, String collectionName, String requestEtag, boolean checkEtag)OperationResultdeleteDatabase(com.mongodb.client.ClientSession cs, String dbName, String 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)Returns true if the collection existsbooleandoesDbExist(com.mongodb.client.ClientSession cs, String dbName)com.mongodb.client.MongoCollection<org.bson.BsonDocument>getCollection(String dbName, String collName)org.bson.BsonArraygetCollectionData(com.mongodb.client.ClientSession cs, com.mongodb.client.MongoCollection<org.bson.BsonDocument> coll, 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)List<String>getCollectionNames(com.mongodb.client.ClientSession cs, String dbName)org.bson.BsonDocumentgetCollectionProperties(com.mongodb.client.ClientSession cs, String dbName, String collName)longgetCollectionSize(com.mongodb.client.ClientSession cs, com.mongodb.client.MongoCollection<org.bson.BsonDocument> coll, org.bson.BsonDocument filters)com.mongodb.client.MongoDatabasegetDatabase(String dbName)org.bson.BsonArraygetDatabaseData(com.mongodb.client.ClientSession cs, String dbName, List<String> colls, int page, int pagesize, boolean noCache)List<String>getDatabaseNames(com.mongodb.client.ClientSession cs)org.bson.BsonDocumentgetDatabaseProperties(com.mongodb.client.ClientSession cs, String dbName)longgetDBSize(List<String> colls)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)Returs the FindIterable of the collection applying sorting, filtering and projection.OperationResultupsertCollection(com.mongodb.client.ClientSession cs, String dbName, String collName, org.bson.BsonDocument content, String requestEtag, boolean updating, boolean patching, boolean checkEtag)OperationResultupsertDB(com.mongodb.client.ClientSession cs, String dbName, org.bson.BsonDocument newContent, String requestEtag, boolean updating, boolean patching, boolean checkEtag)
-
-
-
Method Detail
-
doesDbExist
public boolean doesDbExist(com.mongodb.client.ClientSession cs, String dbName)- Specified by:
doesDbExistin interfaceDatabase- Parameters:
cs- the client sessiondbName-- Returns:
-
doesCollectionExist
public boolean doesCollectionExist(com.mongodb.client.ClientSession cs, String dbName, String collName)Returns true if the collection exists- Specified by:
doesCollectionExistin interfaceDatabase- Parameters:
cs- the client sessiondbName- the database name of the collectioncollName- the collection name- Returns:
- true if the collection exists
-
getDatabase
public com.mongodb.client.MongoDatabase getDatabase(String dbName)
- Specified by:
getDatabasein interfaceDatabase- Parameters:
dbName-- Returns:
- the MongoDatabase
-
getCollectionNames
public List<String> getCollectionNames(com.mongodb.client.ClientSession cs, String dbName)
- Specified by:
getCollectionNamesin interfaceDatabase- Parameters:
cs- the client sessiondbName- the database name of the collection- Returns:
- A ordered List of collection names
-
getDatabaseProperties
public org.bson.BsonDocument getDatabaseProperties(com.mongodb.client.ClientSession cs, String dbName)- Specified by:
getDatabasePropertiesin interfaceDatabase- Parameters:
cs- the client sessiondbName-- Returns:
- the db props
-
getDatabaseData
public org.bson.BsonArray getDatabaseData(com.mongodb.client.ClientSession cs, String dbName, List<String> colls, int page, int pagesize, boolean noCache) throws IllegalQueryParamenterException- Specified by:
getDatabaseDatain interfaceDatabase- Parameters:
cs- the client sessiondbName-colls- the collections list as got from getCollectionNames()page-pagesize-noCache- true to avoid using caching- Returns:
- the db data
- Throws:
IllegalQueryParamenterException
-
upsertDB
public OperationResult upsertDB(com.mongodb.client.ClientSession cs, String dbName, org.bson.BsonDocument newContent, String requestEtag, boolean updating, boolean patching, boolean checkEtag)
-
deleteDatabase
public OperationResult deleteDatabase(com.mongodb.client.ClientSession cs, String dbName, String requestEtag, boolean checkEtag)
- Specified by:
deleteDatabasein interfaceDatabase- Parameters:
cs- the client sessiondbName-requestEtag-- Returns:
-
getCollectionProperties
public org.bson.BsonDocument getCollectionProperties(com.mongodb.client.ClientSession cs, String dbName, String collName)- Specified by:
getCollectionPropertiesin interfaceDatabase- Parameters:
cs- the client sessiondbName-collName-- Returns:
-
getCollection
public com.mongodb.client.MongoCollection<org.bson.BsonDocument> getCollection(String dbName, String collName)
- Specified by:
getCollectionin interfaceDatabase- Parameters:
dbName-collName-- Returns:
-
upsertCollection
public OperationResult upsertCollection(com.mongodb.client.ClientSession cs, String dbName, String collName, org.bson.BsonDocument content, String requestEtag, boolean updating, boolean patching, boolean checkEtag)
- Specified by:
upsertCollectionin interfaceDatabase- Parameters:
cs- the client sessiondbName-collName-content-requestEtag-updating-patching-checkEtag-- Returns:
-
deleteCollection
public OperationResult deleteCollection(com.mongodb.client.ClientSession cs, String dbName, String collectionName, String requestEtag, boolean checkEtag)
- Specified by:
deleteCollectionin interfaceDatabase- Parameters:
cs- the client sessiondbName-collectionName-requestEtag-checkEtag-- Returns:
-
getCollectionSize
public long getCollectionSize(com.mongodb.client.ClientSession cs, com.mongodb.client.MongoCollection<org.bson.BsonDocument> coll, org.bson.BsonDocument filters)- Specified by:
getCollectionSizein interfaceDatabase- Parameters:
cs- the client sessioncoll-filters-- Returns:
-
getCollectionData
public org.bson.BsonArray getCollectionData(com.mongodb.client.ClientSession cs, com.mongodb.client.MongoCollection<org.bson.BsonDocument> coll, 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)- Specified by:
getCollectionDatain interfaceDatabase- Parameters:
cs- the client sessioncoll-page-pagesize-sortBy-filter-hint-keys-cursorAllocationPolicy-- Returns:
-
getDatabaseNames
public List<String> getDatabaseNames(com.mongodb.client.ClientSession cs)
- Specified by:
getDatabaseNamesin interfaceDatabase- Parameters:
cs- the client session- Returns:
-
deleteIndex
public int deleteIndex(com.mongodb.client.ClientSession cs, String dbName, String collection, String indexId)- Specified by:
deleteIndexin interfaceDatabase- Parameters:
cs- the client sessiondbName-collection-indexId-- Returns:
-
getCollectionIndexes
public List<org.bson.BsonDocument> getCollectionIndexes(com.mongodb.client.ClientSession cs, String dbName, String collectionName)
- Specified by:
getCollectionIndexesin interfaceDatabase- Parameters:
cs- the client sessiondbName-collectionName-- Returns:
-
getFindIterable
public 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)Description copied from interface:DatabaseReturs the FindIterable of the collection applying sorting, filtering and projection.- Specified by:
getFindIterablein interfaceDatabase- Parameters:
cs- the client sessioncollection-sortBy-filters-hint-keys-- Returns:
-
createIndex
public void createIndex(com.mongodb.client.ClientSession cs, String dbName, String collection, org.bson.BsonDocument keys, org.bson.BsonDocument options)- Specified by:
createIndexin interfaceDatabase- Parameters:
cs- the client sessiondbName-collection-keys-options-
-
-