Package io.nitric.api.document
Class DocumentRef<T>
- java.lang.Object
-
- io.nitric.api.document.DocumentRef<T>
-
public class DocumentRef<T> extends Object
Provides an Document Reference class.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection
collection(String name)
Create a new sub collection under this document.void
delete()
Delete this document reference from the database if it exists.T
get()
Return the document reference content value.Key
getKey()
Return the document's key.DocumentRef<T>
objectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Set the Document content object marshalling ObjectMapper.Query<Map>
query(String name)
Create a new sub collection query for this Document Ref.<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.void
set(T content)
Set the document content for this document reference in the database.String
toString()
Return the string representation of this object.
-
-
-
Method Detail
-
getKey
public Key getKey()
Return the document's key.- Returns:
- the document's key
-
get
public T get() throws NotFoundException, NitricException
Return the document reference content value.- Returns:
- the document reference content value
- Throws:
NotFoundException
- if the document was not foundNitricException
- if a Document Service API error occurs
-
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 aMap
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
-
-