Class StargateDocumentRepository<DOC>

java.lang.Object
io.stargate.sdk.doc.StargateDocumentRepository<DOC>
Type Parameters:
DOC - current document bean.

public class StargateDocumentRepository<DOC> extends Object
Super class helping you to work with the document API.
Author:
Cedrick LUNVEN (@clunven)
  • Constructor Details

    • StargateDocumentRepository

      public StargateDocumentRepository(CollectionClient col, Class<DOC> clazz)
      Default constructor.
      Parameters:
      col - collection client parent
      clazz - working bean class
    • StargateDocumentRepository

      public StargateDocumentRepository(NamespaceClient nc, Class<DOC> clazz)
      Constructor from NamespaceClient.
      Parameters:
      nc - reference to the StargateClient
      clazz - working namespace identifier
  • Method Details

    • count

      public long count()
      Count items in the collection.
      Returns:
      number of records.
    • delete

      public void delete(String docId)
      Delete a document from its iid.
      Parameters:
      docId - document identifier
    • exists

      public boolean exists(String docId)
      Check existence of a document from its id.
      Parameters:
      docId - document identifier
      Returns:
      existence status
    • insert

      public String insert(DOC p)
      Create a new document a generating identifier.
      Parameters:
      p - working document
      Returns:
      an unique identifier for the document
    • insert

      public void insert(String docId, DOC doc)
      Create if not exist with defined ID.
      Parameters:
      docId - expected document id
      doc - document
    • save

      public void save(String docId, DOC doc)
      Create if not exist with defined ID.
      Parameters:
      docId - expected document id
      doc - document
    • getCollectionName

      public String getCollectionName()
      Evaluation on which collection we are working.
      Returns:
      collection identifier
    • find

      public Optional<DOC> find(String docId)
      Find a person from ids unique identifier.
      Parameters:
      docId - document Id
      Returns:
      the object only if present
    • findAll

      public Stream<Document<DOC>> findAll()
      Retrieve all documents from the collection.
      Returns:
      every document of the collection
    • findAll

      public Stream<Document<DOC>> findAll(Query query)
      Search document based on a search query
      Parameters:
      query - current query
      Returns:
      all the element matching
    • findPage

      public Page<Document<DOC>> findPage(PageableQuery query)
      Search document with attributes.
      Parameters:
      query - current query
      Returns:
      result page