Class DocumentRef<T>


  • public class DocumentRef<T>
    extends Object
    Provides an Document Reference class.
    • Method Detail

      • getKey

        public Key getKey()
        Return the document's key.
        Returns:
        the document's key
      • set

        public void set​(T content)
                 throws NitricException
        Set the document content for this document reference in the database. If the document does not exist an new item will be created, otherwise an existing document will be update with the new value.
        Parameters:
        content - the document content to store (required)
        Throws:
        NitricException - if a Document Service API error occurs
      • delete

        public void delete()
                    throws NitricException
        Delete this document reference from the database if it exists.
        Throws:
        NitricException - if a Document Service API error occurs
      • collection

        public Collection collection​(String name)
        Create a new sub collection under this document.
        Parameters:
        name - the name of the sub collection (required)
        Returns:
        a new sub collection for the parent collection
      • query

        public Query<Map> query​(String name)
        Create a new sub collection query for this Document Ref. The query object will have a Map value type.
        Parameters:
        name - the name of the sub collection (required)
        Returns:
        a new collection query object
      • query

        public <K> Query<K> query​(String name,
                                  Class<K> type)
        Create a new sub collection query for this Document Ref, and with the given value type.
        Parameters:
        name - the name of the sub collection (required)
        type - the query value type (required)
        Returns:
        a new collection query object
      • objectMapper

        public DocumentRef<T> objectMapper​(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
        Set the Document content object marshalling ObjectMapper.
        Parameters:
        objectMapper - the Document content object marshalling ObjectMapper
        Returns:
        this Document Ref object
      • toString

        public String toString()
        Return the string representation of this object.
        Overrides:
        toString in class Object
        Returns:
        the string representation of this object