Document Manager

The manager class to a document type can be synchronous or asynchronous:

  • DocumentCollectionManager: To do synchronous operations.

  • DocumentCollectionManagerAsync: To do asynchronous operations.

DocumentCollectionManager

The DocumentCollectionManager is the class that manages the persistence on the synchronous way to document collection.

        DocumentEntity entity = DocumentEntity.of("collection");
        Document diana = Document.of("name", "Diana");
        entity.add(diana);

        List<DocumentEntity> entities = Collections.singletonList(entity);
        DocumentCollectionManager manager = //instance;

        //insert operations
        manager.insert(entity);
        manager.insert(entity, Duration.ofHours(2L));//inserts with 2 hours of TTL
        manager.insert(entities, Duration.ofHours(2L));//inserts with 2 hours of TTL
        //updates operations
        manager.update(entity);
        manager.update(entities);

DocumentCollectionManagerAsync

The DocumentCollectionManagerAsync is the class that manages the persistence on an asynchronous way to document collection.

Sometimes on an asynchronous process, is important to know when this process is over, so the DocumentCollectionManagerAsync also has callback support.

Search information on a document collection

Diana has support to retrieve information from both ways synchronous and asynchronous from the DocumentQuery class. The DocumentQuery has information such as sort type, document and also the condition to retrieve information.

The condition on DocumentQuery is given from DocumentCondition, which has the status and the document. Eg. The condition behind is to find a name equal "Ada".

Also, the developer can use the aggregators such as AND, OR e NOT.

If there isn't a condition in the query that means the query will try to retrieve all information from the database, similar to a “select * from database” in a relational database, just remembering that the return depends on the driver. It is important to say that not all NoSQL databases have support for this resource.

DocumentQuery also has pagination feature to define where the data start, and it limits.

Removing information from Document Collection

Such as DocumentQuery there is a class to remove information from the document database type: A DocumentDeleteQuery type.

It is smoother than DocumentQuery because there isn't pagination and sort feature, once this information is unnecessary to remove information from database.

Last updated