PhoenixmlDb.Core
DocumentOptions
Options controlling how a document is stored when calling .
#DocumentOptions
Namespace: PhoenixmlDb.Core
Options controlling how a document is stored when calling
.
All properties have sensible defaults: content type is auto-detected, overwrite is enabled, and no initial metadata is set. You only need to create a DocumentOptions instance when you want to override one of these defaults.
Common scenarios requiring explicit options:
-
Insert-only semantics: Set
DocumentOptions.Overwritetofalseto get aDocumentExistsExceptionif the document name is already taken. -
Ambiguous content: Set
DocumentOptions.ContentTypeexplicitly when the auto-detection might misidentify the format (e.g., a JSON document whose first non-whitespace character could be interpreted as XML). -
Initial metadata: Set
DocumentOptions.Metadatato attach key-value pairs at creation time, rather than making a separateIContainer.SetMetadataAsynccall.
#Example
var options = new DocumentOptions
{
ContentType = ContentType.Xml,
Overwrite = false,
Metadata = new Dictionary<string, object>
{
["author"] = "Jane Smith",
["department"] = "Engineering"
}
};
await container.PutDocumentAsync("reports/q1-2024.xml", xmlContent, options);
#Properties
| Name | Description |
|---|---|
ContentType
|
Gets the content type (XML or JSON) for the document. When null (the default), the content type is auto-detected from the document content.
|
Metadata
|
Gets the initial metadata to attach to the document at creation time. When null (the default), no metadata is set.
|
Overwrite
|
Gets whether to overwrite an existing document with the same name. Defaults to true.
|