Package io.stargate.sdk.doc
Class DocumentClient
java.lang.Object
io.stargate.sdk.doc.DocumentClient
Part of the Document API in stargate wrapper for methods at the document level.
- Author:
- Cedrick LUNVEN (@clunven)
-
Field Summary
FieldsModifier and TypeFieldDescription/v2/schemas/namespaces/{namespace}/collections/{collection}/{docId} -
Constructor Summary
ConstructorsConstructorDescriptionDocumentClient(LoadBalancedHttpClient stargateHttpClient, CollectionClient collectionClient, String docId) Full constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete()Delete a document.voiddeleteSubDocument(String path) Delete a sub document.executefunction(String path, String function, Object value) Execute a function on a document.booleanexist()Leverage find() to check existence without eventual formatting issues.find()Get a document by id.<DOC> Optional<DOC> find(RecordMapper<DOC> docm) Get a document by id.<DOC> Optional<DOC> Get a document by {document-id}.findSubDocument(String path) Retrieve a sub document with no marshalling<SUBDOC> Optional<SUBDOC> findSubDocument(String path, Class<SUBDOC> className) Get a sub document by {document-path}.voidreplaceSubDocument(String path, String newValue) Replace a subpart of the document.<SUBDOC> voidreplaceSubDocument(String path, SUBDOC newValue) Replace a subpart of the document.<DOC> Stringupdate(DOC doc) Update part of a document.Update a document providing only the Json.voidupdateSubDocument(String path, String newValue) Update a subpart of the document.<SUBDOC> voidupdateSubDocument(String path, SUBDOC newValue) Update part of a sub document https://docs.datastax.com/en/astra/docs/_attachments/docv2.html#operation/updatePartOfSubDoc<DOC> Stringupsert(DOC doc) Replace a document.Replace a document providing only the Json.
-
Field Details
-
documentResource
/v2/schemas/namespaces/{namespace}/collections/{collection}/{docId}
-
-
Constructor Details
-
DocumentClient
public DocumentClient(LoadBalancedHttpClient stargateHttpClient, CollectionClient collectionClient, String docId) Full constructor.- Parameters:
stargateHttpClient- stargateHttpClientcollectionClient- CollectionClientdocId- String
-
-
Method Details
-
exist
public boolean exist()Leverage find() to check existence without eventual formatting issues. https://docs.datastax.com/en/astra/docs/_attachments/docv2.html#operation/getDocById- Returns:
- boolean
-
upsert
Replace a document. https://docs.datastax.com/en/astra/docs/_attachments/docv2.html#operation/replaceDoc- Type Parameters:
DOC- working class- Parameters:
doc- object to be updated- Returns:
- the unique document identifier
-
upsert
Replace a document providing only the Json.- Parameters:
json- jon file.- Returns:
- the unique document identifier
-
update
Update part of a document. https://docs.datastax.com/en/astra/docs/_attachments/docv2.html#operation/updatePartOfDoc- Type Parameters:
DOC- working class- Parameters:
doc- working class- Returns:
- DOC
-
update
Update a document providing only the Json.- Parameters:
json- jon file.- Returns:
- the unique document identifier
-
find
Get a document by id.- Returns:
- the json payload if document exists.
-
find
Get a document by id.- Type Parameters:
DOC- nea- Parameters:
docm- document mapper- Returns:
- a document if exist
-
find
Get a document by {document-id}. https://docs.datastax.com/en/astra/docs/_attachments/docv2.html#operation/getDocById- Type Parameters:
DOC- working class- Parameters:
clazz- working class- Returns:
- a document if exist
-
delete
public void delete()Delete a document. https://docs.datastax.com/en/astra/docs/_attachments/docv2.html#operation/deleteDoc -
findSubDocument
Get a sub document by {document-path}. https://docs.datastax.com/en/astra/docs/_attachments/docv2.html#operation/GetSubDocByPath- Type Parameters:
SUBDOC- working class- Parameters:
path- subpath in the docclassName- working class- Returns:
- SUBDOC
-
findSubDocument
Retrieve a sub document with no marshalling- Parameters:
path- path of the document- Returns:
- value as a String
-
executefunction
Execute a function on a document.- Parameters:
path- current document sub pathfunction- function executed.value- value for attribute to update- Returns:
- attribute updated
-
replaceSubDocument
Replace a subpart of the document. https://docs.datastax.com/en/astra/docs/_attachments/docv2.html#operation/replaceSubDoc- Type Parameters:
SUBDOC- working class- Parameters:
path- subpath in the docnewValue- object for the new value
-
replaceSubDocument
Replace a subpart of the document.- Parameters:
path- sub pathnewValue- new value for the path
-
updateSubDocument
Update part of a sub document https://docs.datastax.com/en/astra/docs/_attachments/docv2.html#operation/updatePartOfSubDoc- Type Parameters:
SUBDOC- working class- Parameters:
path- subpath in the docnewValue- object for the new value
-
updateSubDocument
Update a subpart of the document.- Parameters:
path- sub pathnewValue- new value for the path
-
deleteSubDocument
Delete a sub document. https://docs.datastax.com/en/astra/docs/_attachments/docv2.html#operation/deleteSubDoc- Parameters:
path- sub document path
-