Class DatabaseImpl

java.lang.Object
org.restheart.mongodb.db.DatabaseImpl
All Implemented Interfaces:
Database

public class DatabaseImpl extends Object implements Database
Author:
Andrea Di Cesare <andrea@softinstigate.com>
  • Field Details

    • PROPS_QUERY

      public static final org.bson.conversions.Bson PROPS_QUERY
  • Constructor Details

    • DatabaseImpl

      public DatabaseImpl()
  • Method Details

    • doesDbExist

      public boolean doesDbExist(com.mongodb.client.ClientSession cs, String dbName)
      Specified by:
      doesDbExist in interface Database
      Parameters:
      cs - the client session
      dbName -
      Returns:
    • doesCollectionExist

      public boolean doesCollectionExist(com.mongodb.client.ClientSession cs, String dbName, String collName)
      Returns true if the collection exists
      Specified by:
      doesCollectionExist in interface Database
      Parameters:
      cs - the client session
      dbName - the database name of the collection
      collName - the collection name
      Returns:
      true if the collection exists
    • getDatabase

      public com.mongodb.client.MongoDatabase getDatabase(String dbName)
      Specified by:
      getDatabase in interface Database
      Parameters:
      dbName -
      Returns:
      the MongoDatabase
    • getCollectionNames

      public List<String> getCollectionNames(com.mongodb.client.ClientSession cs, String dbName)
      Specified by:
      getCollectionNames in interface Database
      Parameters:
      cs - the client session
      dbName - the database name of the collection
      Returns:
      A ordered List of collection names
    • getDBSize

      public long getDBSize(List<String> colls)
      Specified by:
      getDBSize in interface Database
      Parameters:
      colls - the collections list got from getCollectionNames()
      Returns:
      the number of collections in this db
    • getDatabaseProperties

      public org.bson.BsonDocument getDatabaseProperties(com.mongodb.client.ClientSession cs, String dbName)
      Specified by:
      getDatabaseProperties in interface Database
      Parameters:
      cs - the client session
      dbName -
      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:
      getDatabaseData in interface Database
      Parameters:
      cs - the client session
      dbName -
      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)
      Specified by:
      upsertDB in interface Database
      Parameters:
      cs - the client session
      dbName -
      newContent -
      requestEtag -
      patching -
      Returns:
    • deleteDatabase

      public OperationResult deleteDatabase(com.mongodb.client.ClientSession cs, String dbName, org.bson.BsonObjectId requestEtag, boolean checkEtag)
      Specified by:
      deleteDatabase in interface Database
      Parameters:
      cs - the client session
      dbName -
      requestEtag -
      checkEtag -
      Returns:
    • getCollectionProperties

      public org.bson.BsonDocument getCollectionProperties(com.mongodb.client.ClientSession cs, String dbName, String collName)
      Specified by:
      getCollectionProperties in interface Database
      Parameters:
      cs - the client session
      dbName -
      collName -
      Returns:
    • getCollection

      public com.mongodb.client.MongoCollection<org.bson.BsonDocument> getCollection(String dbName, String collName)
      Specified by:
      getCollection in interface Database
      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:
      upsertCollection in interface Database
      Parameters:
      cs - the client session
      dbName -
      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:
      deleteCollection in interface Database
      Parameters:
      cs - the client session
      dbName -
      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:
      getCollectionSize in interface Database
      Parameters:
      cs - the client session
      coll -
      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:
      getCollectionData in interface Database
      Parameters:
      cs - the client session
      coll -
      page -
      pagesize -
      sortBy -
      filter -
      hint -
      keys -
      cursorAllocationPolicy -
      Returns:
    • getDatabaseNames

      public List<String> getDatabaseNames(com.mongodb.client.ClientSession cs)
      Specified by:
      getDatabaseNames in interface Database
      Parameters:
      cs - the client session
      Returns:
    • deleteIndex

      public int deleteIndex(com.mongodb.client.ClientSession cs, String dbName, String collection, String indexId)
      Specified by:
      deleteIndex in interface Database
      Parameters:
      cs - the client session
      dbName -
      collection -
      indexId -
      Returns:
    • getCollectionIndexes

      public List<org.bson.BsonDocument> getCollectionIndexes(com.mongodb.client.ClientSession cs, String dbName, String collectionName)
      Specified by:
      getCollectionIndexes in interface Database
      Parameters:
      cs - the client session
      dbName -
      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: Database
      Returs the FindIterable of the collection applying sorting, filtering and projection.
      Specified by:
      getFindIterable in interface Database
      Parameters:
      cs - the client session
      collection -
      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:
      createIndex in interface Database
      Parameters:
      cs - the client session
      dbName -
      collection -
      keys -
      options -