Class MongoCollections

java.lang.Object
org.graylog2.database.MongoCollections

@Singleton public class MongoCollections extends Object
  • Constructor Details

  • Method Details

    • get

      @Deprecated public <T> com.mongodb.client.MongoCollection<T> get(String collectionName, Class<T> valueType)
      Get a MongoCollection configured to use Jackson for serialization/deserialization of objects.

      Prefer using collection(String, Class) to get a more strictly typed collection!

    • nonEntityCollection

      public <T> com.mongodb.client.MongoCollection<T> nonEntityCollection(String collectionName, Class<T> valueType)
      Get a MongoCollection for document types that don't implement MongoEntity.

      Prefer using collection(String, Class). Only use this method if, for some reason, the document class cannot implement the MongoEntity interface.

      Parameters:
      collectionName - Name of the collection
      valueType - Java type of the documents stored in the collection
      Returns:
      A collection using a Jackson codec for serialization and deserialization
    • collection

      public <T extends MongoEntity> com.mongodb.client.MongoCollection<T> collection(String collectionName, Class<T> valueType)
      Get a MongoCollection configured to use Jackson for serialization/deserialization of objects.
      Parameters:
      collectionName - Name of the collection
      valueType - Java type of the documents stored in the collection
      Returns:
      A collection using a Jackson codec for serialization and deserialization
    • paginationHelper

      public <T extends MongoEntity> MongoPaginationHelper<T> paginationHelper(String collectionName, Class<T> valueType)
      Provides a helper to perform find operations on a collection that yield pages of documents.
    • paginationHelper

      public <T extends MongoEntity> MongoPaginationHelper<T> paginationHelper(com.mongodb.client.MongoCollection<T> collection)
      Provides a helper to perform find operations on a collection that yield pages of documents.
    • utils

      public <T extends MongoEntity> MongoUtils<T> utils(String collectionName, Class<T> valueType)
      Provides utility methods like getting documents by ID, etc.
    • utils

      public <T extends MongoEntity> MongoUtils<T> utils(com.mongodb.client.MongoCollection<T> collection)
      Provides utility methods like getting documents by ID, etc.
    • scopedEntityUtils

      public <T extends ScopedEntity> ScopedEntityMongoUtils<T> scopedEntityUtils(com.mongodb.client.MongoCollection<T> collection, EntityScopeService entityScopeService)
      Provides utility methods for creating, updating, and deleting ScopedEntity objects