Package dev.morphia

Interface AdvancedDatastore

  • All Superinterfaces:
    Datastore

    public interface AdvancedDatastore
    extends Datastore
    This interface exposes advanced Datastore features, like interacting with DBObject and low-level options. It implements matching methods from the Datastore interface but with a specified kind (collection name), or raw types (DBObject).
    Author:
    ScottHernandez
    • Method Detail

      • createAggregation

        AggregationPipeline createAggregation​(java.lang.String collection,
                                              java.lang.Class<?> clazz)
        Returns an AggregationPipeline bound to the given collection and class.
        Parameters:
        collection - the collection to query
        clazz - The class to create aggregation against
        Returns:
        the aggregation pipeline
      • createQuery

        <T> Query<T> createQuery​(java.lang.String collection,
                                 java.lang.Class<T> clazz)
        Type Parameters:
        T - The type of the entity
        Parameters:
        collection - the collection to query
        clazz - the class of objects to be returned
        Returns:
        Query for the specified class clazz
      • createQuery

        <T> Query<T> createQuery​(java.lang.Class<T> clazz,
                                 com.mongodb.DBObject q)
        Type Parameters:
        T - The type of the entity
        Parameters:
        clazz - the class of objects to be returned
        q - the query which will be passed to a QueryFactory
        Returns:
        Query for the specified class clazz
      • createRef

        <T,​V> com.mongodb.DBRef createRef​(java.lang.Class<T> clazz,
                                                V id)
        Creates a reference to the entity (using the current DB -can be null-, the collectionName, and id)
        Type Parameters:
        T - The type of the entity
        V - The type of the ID value
        Parameters:
        clazz - The type of the entity
        id - The ID value of the entity
        Returns:
        the DBRef for the entity
      • createRef

        <T> com.mongodb.DBRef createRef​(T entity)
        Creates a reference to the entity (using the current DB -can be null-, the collectionName, and id)
        Type Parameters:
        T - The type of the entity
        Parameters:
        entity - the entity to create a DBRef for
        Returns:
        the DBRef for the entity
      • createUpdateOperations

        @Deprecated(since="2.0",
                    forRemoval=true)
        <T> UpdateOperations<T> createUpdateOperations​(java.lang.Class<T> type,
                                                       com.mongodb.DBObject ops)
        Deprecated, for removal: This API element is subject to removal in a future version.
        use Query.update() instead
        Creates an UpdateOperations instance for the given type.
        Type Parameters:
        T - The type of the entity
        Parameters:
        type - The type of the entity
        ops - The operations to perform
        Returns:
        the UpdateOperations instance
      • find

        <T> Query<T> find​(java.lang.String collection)
        Find all instances by type in a different collection than what is mapped on the class given.
        Type Parameters:
        T - the type to query
        Parameters:
        collection - the collection to query against
        Returns:
        the query
        Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • insert

        <T> Key<T> insert​(T entity)
        Inserts an entity in to the mapped collection.
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to insert
        Returns:
        the new key of the inserted entity
      • insert

        <T> Key<T> insert​(T entity,
                          InsertOptions options)
        Inserts an entity in to the mapped collection.
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to insert
        options - the options to apply to the insert operation
        Returns:
        the new key of the inserted entity
        Since:
        1.3
        Developer note. Inline this method to update to the new usage
      • insert

        default <T> java.lang.Iterable<Key<T>> insert​(java.lang.Iterable<T> entities)
        Inserts entities in to the mapped collection.
        Type Parameters:
        T - the type of the entities
        Parameters:
        entities - the entities to insert
        Returns:
        the new keys of the inserted entities
      • insert

        <T> java.lang.Iterable<Key<T>> insert​(java.lang.Iterable<T> entities,
                                              InsertOptions options)
        Inserts entities in to the mapped collection.
        Type Parameters:
        T - the type of the entity
        Parameters:
        entities - the entities to insert
        options - the options to apply to the insert operation
        Returns:
        the new keys of the inserted entities
        Since:
        1.3
        Developer note. Inline this method to update to the new usage
      • queryByExample

        <T> Query<T> queryByExample​(java.lang.String collection,
                                    T example)
        Returns a new query based on the example object
        Type Parameters:
        T - the type of the entity
        Parameters:
        collection - the collection to query
        example - the example entity to use when building the query
        Returns:
        the query