共用方式為


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.

Document(JSONObject jsonObject)

Initialize a document object from json object.

Method Summary

Modifier and Type Method and Description
java.lang.Integer getTimeToLive()

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

void setTimeToLive(Integer timeToLive)

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

Methods inherited from JsonSerializable

Methods inherited from Resource

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

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

Document

public Document(JSONObject jsonObject)

Initialize a document object from json object.

Parameters:

jsonObject - the json object that represents the document object.

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