Class DatastoreImpl

java.lang.Object
io.mangoo.persistence.DatastoreImpl
All Implemented Interfaces:
Datastore

public class DatastoreImpl extends Object implements Datastore
Author:
svenkubiak
  • Constructor Details

    • DatastoreImpl

      @Inject public DatastoreImpl(Config config, EventBusService eventBus)
    • DatastoreImpl

      public DatastoreImpl(String prefix)
  • Method Details

    • getDatastore

      public dev.morphia.Datastore getDatastore()
      Specified by:
      getDatastore in interface Datastore
    • query

      public dev.morphia.Datastore query()
      Specified by:
      query in interface Datastore
    • getMongoClient

      public com.mongodb.client.MongoClient getMongoClient()
      Specified by:
      getMongoClient in interface Datastore
    • ensureIndexes

      public void ensureIndexes()
      Description copied from interface: Datastore
      Ensures (creating if necessary) the indexes found during class mapping (using @Indexed, @Indexes)
      Specified by:
      ensureIndexes in interface Datastore
    • ensureCaps

      public void ensureCaps()
      Description copied from interface: Datastore
      Ensure capped DBCollections for Entity(s)
      Specified by:
      ensureCaps in interface Datastore
    • findById

      public <T> T findById(String id, Class<T> clazz)
      Description copied from interface: Datastore
      Retrieves a mapped Morphia object from MongoDB.
      Specified by:
      findById in interface Datastore
      Type Parameters:
      T - JavaDoc requires this - please ignore
      Parameters:
      id - The mongodb id of the object
      clazz - The mapped Morphia class
      Returns:
      The requested class from MongoDB or null if none found
    • findAll

      public <T> List<T> findAll(Class<T> clazz)
      Description copied from interface: Datastore
      Retrieves a list of mapped Morphia objects from MongoDB
      Specified by:
      findAll in interface Datastore
      Type Parameters:
      T - JavaDoc requires this - please ignore
      Parameters:
      clazz - The mapped Morphia class
      Returns:
      A list of mapped Morphia objects or an empty list if none found
    • countAll

      public <T> long countAll(Class<T> clazz)
      Description copied from interface: Datastore
      Counts all objected of a mapped Morphia class
      Specified by:
      countAll in interface Datastore
      Type Parameters:
      T - JavaDoc requires this - please ignore
      Parameters:
      clazz - The mapped Morphia class
      Returns:
      The number of objects in MongoDB
    • save

      public void save(Object object)
      Description copied from interface: Datastore
      Saves a mapped Morphia object to MongoDB
      Specified by:
      save in interface Datastore
      Parameters:
      object - The object to save
    • saveAsync

      public void saveAsync(Object object)
      Description copied from interface: Datastore
      Saves a mapped Morphia object to MongoDB asynchronously
      Specified by:
      saveAsync in interface Datastore
      Parameters:
      object - The object to save
    • delete

      public void delete(Object object)
      Description copied from interface: Datastore
      Deletes a mapped Morphia object in MongoDB
      Specified by:
      delete in interface Datastore
      Parameters:
      object - The object to delete
    • deleteAsync

      public void deleteAsync(Object object)
      Description copied from interface: Datastore
      Deletes a mapped Morphia object to MongoDB asynchronously
      Specified by:
      deleteAsync in interface Datastore
      Parameters:
      object - The object to delete
    • deleteAll

      public <T> void deleteAll(Class<T> clazz)
      Description copied from interface: Datastore
      Deletes all mapped Morphia objects of a given class
      Specified by:
      deleteAll in interface Datastore
      Type Parameters:
      T - JavaDoc requires this - please ignore
      Parameters:
      clazz - The mapped Morphia class
    • dropDatabase

      public void dropDatabase()
      Description copied from interface: Datastore
      Drops all data in MongoDB on the connected database
      Specified by:
      dropDatabase in interface Datastore