Package org.restheart.mongodb.db
Class DatabaseImpl
java.lang.Object
org.restheart.mongodb.db.DatabaseImpl
- All Implemented Interfaces:
Database
- Author:
- Andrea Di Cesare <andrea@softinstigate.com>
-
Field Summary
Fields -
Constructor Summary
Constructors -
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)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)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)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 collName, org.bson.BsonDocument content, String requestEtag, boolean updating, boolean patching, boolean checkEtag)upsertDB(com.mongodb.client.ClientSession cs, String dbName, org.bson.BsonDocument newContent, String requestEtag, boolean updating, boolean patching, boolean checkEtag)
-
Field Details
-
PROPS_QUERY
public static final org.bson.conversions.Bson PROPS_QUERY
-
-
Constructor Details
-
DatabaseImpl
public DatabaseImpl()
-
-
Method Details
-
doesDbExist
- 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
- Specified by:
getDatabasein interfaceDatabase- Parameters:
dbName-- Returns:
- the MongoDatabase
-
getCollectionNames
- Specified by:
getCollectionNamesin interfaceDatabase- Parameters:
cs- the client sessiondbName- the database name of the collection- Returns:
- A ordered List of collection names
-
getDBSize
-
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, org.bson.BsonObjectId requestEtag, boolean checkEtag)- Specified by:
deleteDatabasein interfaceDatabase- Parameters:
cs- the client sessiondbName-requestEtag-checkEtag-- 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, org.bson.BsonObjectId 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
- 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-
-