Interface Database

All Known Implementing Classes:
DatabaseImpl

public interface Database
Author:
Maurizio Turatti <maurizio@softinstigate.com>
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    createIndex​(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)
     
    int
    deleteIndex​(com.mongodb.client.ClientSession cs, String dbName, String collection, String indexId)
     
    boolean
    doesCollectionExist​(com.mongodb.client.ClientSession cs, String dbName, String collName)
     
    boolean
    doesDbExist​(com.mongodb.client.ClientSession cs, String dbName)
     
    com.mongodb.client.MongoCollection<org.bson.BsonDocument>
    getCollection​(String dbName, String collectionName)
     
    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)
     
    List<org.bson.BsonDocument>
    getCollectionIndexes​(com.mongodb.client.ClientSession cs, String dbName, String collectionName)
     
    getCollectionNames​(com.mongodb.client.ClientSession cs, String dbName)
     
    org.bson.BsonDocument
    getCollectionProperties​(com.mongodb.client.ClientSession cs, String dbName, String collectionName)
     
    long
    getCollectionSize​(com.mongodb.client.ClientSession cs, com.mongodb.client.MongoCollection<org.bson.BsonDocument> collection, org.bson.BsonDocument filters)
     
    com.mongodb.client.MongoDatabase
    getDatabase​(String dbName)
     
    org.bson.BsonArray
    getDatabaseData​(com.mongodb.client.ClientSession cs, String dbName, List<String> collections, int page, int pagesize, boolean noCache)
     
    getDatabaseNames​(com.mongodb.client.ClientSession cs)
     
    org.bson.BsonDocument
    getDatabaseProperties​(com.mongodb.client.ClientSession cs, String dbName)
     
    long
    getDBSize​(List<String> collections)
     
    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.
    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 session
      dbName -
      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 session
      dbName -
      requestEtag -
      checkEtag -
      Returns:
      HTTP status code
    • doesDbExist

      boolean doesDbExist(com.mongodb.client.ClientSession cs, String dbName)
      Parameters:
      cs -
      dbName -
      Returns:
      true if DB dbName exists
    • doesCollectionExist

      boolean doesCollectionExist(com.mongodb.client.ClientSession cs, String dbName, String collName)
      Parameters:
      cs - the client session
      dbName -
      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 session
      collection -
      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 session
      dbName -
      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 session
      collection -
      filters -
      Returns:
      the number of documents in the given collection (taking into account the filters in case)
    • getDatabase

      com.mongodb.client.MongoDatabase getDatabase(String dbName)
      Parameters:
      dbName -
      Returns:
      the MongoDatabase
    • getDBSize

      long getDBSize(List<String> collections)
      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 session
      dbName -
      collections - the collections list as got from getCollectionNames()
      page -
      pagesize -
      noCache - true to avoid using caching
      Returns:
      the db data
      Throws:
      IllegalQueryParamenterException
    • getDatabaseNames

      List<String> getDatabaseNames(com.mongodb.client.ClientSession cs)
      Parameters:
      cs - the client session
      Returns:
      A List of database names
    • getCollectionNames

      List<String> getCollectionNames(com.mongodb.client.ClientSession cs, String dbName)
      Parameters:
      cs - the client session
      dbName -
      Returns:
      A List of collection names
    • getDatabaseProperties

      org.bson.BsonDocument getDatabaseProperties(com.mongodb.client.ClientSession cs, String dbName)
      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 session
      dbName -
      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 session
      dbName -
      content -
      requestEtag -
      updating -
      patching -
      checkEtag -
      Returns:
    • deleteIndex

      int deleteIndex(com.mongodb.client.ClientSession cs, String dbName, String collection, String indexId)
      Parameters:
      cs - the client session
      dbName -
      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 session
      dbName -
      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 session
      dbName -
      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.JsonParseException
      Returs the FindIterable of the collection applying sorting, filtering and projection.
      Parameters:
      cs - the client session
      collection - the mongodb MongoCollection<BsonDocument> object
      sortBy - 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