Sdílet prostřednictvím


Document Class

public class Document extends Resource

Represents a document in the Azure Cosmos DB database service.

A document is a structured JSON document. There is no set schema for the JSON documents, and a document may contain any number of custom properties as well as an optional list of attachments. Document is an application resource and can be authorized using the master key or resource keys.

Constructor Summary

Constructor Description
Document()

Initialize a document object.

Document(String jsonString)

Initialize a document object from json string.

Document(String jsonString, ObjectMapper objectMapper)

Initialize a document object from json string.

Method Summary

Modifier and Type Method and Description
Integer getTimeToLive()

Gets the document's time-to-live value.

void setTimeToLive(Integer timeToLive)

Sets the document's time-to-live value.

A document's time-to-live value is an optional property. If set, the document expires after the specified number of seconds since its last write time. The value of this property should be one of the following:

null - indicates the time-to-live value for this document inherits from the parent collection's default time-to-live value.

nonzero positive integer - indicates the number of seconds before the document expires. It overrides the default time-to-live value specified on the parent collection, unless the parent collection's default time-to-live is null.

-1 - indicates the document never expires. It overrides the default time-to-live value specified on the parent collection, unless the parent collection's default time-to-live is null.

Inherited Members

Constructor Details

Document

public Document()

Initialize a document object.

Document

public Document(String jsonString)

Initialize a document object from json string.

Parameters:

jsonString - the json string that represents the document object.

Document

public Document(String jsonString, ObjectMapper objectMapper)

Initialize a document object from json string.

Parameters:

jsonString - the json string that represents the document object.
objectMapper - the custom object mapper

Method Details

getTimeToLive

public Integer getTimeToLive()

Gets the document's time-to-live value.

Returns:

the document's time-to-live value in seconds.

setTimeToLive

public void setTimeToLive(Integer timeToLive)

Sets the document's time-to-live value.

A document's time-to-live value is an optional property. If set, the document expires after the specified number of seconds since its last write time. The value of this property should be one of the following:

null - indicates the time-to-live value for this document inherits from the parent collection's default time-to-live value.

nonzero positive integer - indicates the number of seconds before the document expires. It overrides the default time-to-live value specified on the parent collection, unless the parent collection's default time-to-live is null.

-1 - indicates the document never expires. It overrides the default time-to-live value specified on the parent collection, unless the parent collection's default time-to-live is null.

Parameters:

timeToLive - the document's time-to-live value in seconds.

Applies to