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 collection document reference value.Key
getKey()
Return the document's key.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()
Return the collection document reference value.- Returns:
- the collection document reference value, or null if not found
-
set
public void set(T content)
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)
-
delete
public void delete()
Delete this document reference from the database if it exists.
-
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
-
-