Table of Contents

Class UpdateItemRequest

Namespace
DynaSharp.Requests
Assembly
DynaSharp.dll

Changes the attributes of an existing item, or creates the item if no item has the key (DynamoDB UpdateItem).

public sealed record UpdateItemRequest : IEquatable<UpdateItemRequest>
Inheritance
UpdateItemRequest
Implements
Inherited Members

Remarks

The update is atomic and changes only the attributes the UpdateExpression names; everything else stays as it is. Without an UpdateExpression a missing item is created with only its key.

Constructors

UpdateItemRequest()

public UpdateItemRequest()

Properties

ConditionExpression

Gets a condition on the existing item that must hold for the update to be applied, for example "attribute_exists(pk) AND version = :expected". When it does not hold, the call throws ConditionalCheckFailedException and nothing changes. A missing item satisfies only conditions such as attribute_not_exists(...). At most 4 KB. Attribute names that are DynamoDB reserved words, such as name, status, size, order or total, must be aliased with a #placeholder defined in ExpressionAttributeNames; written directly, DynamoDB rejects the request with a ValidationException. See the list of reserved words.

public string? ConditionExpression { get; init; }

Property Value

string

ExpressionAttributeNames

Gets the substitutions for #name placeholders in the update and condition expressions. Use them for attribute names that are reserved words (such as Name or Status) or contain special characters. A placeholder that no expression uses makes DynamoDB reject the request. Use it to alias attribute names that are DynamoDB reserved words, such as name, status, size, order or total, which DynamoDB rejects with a ValidationException when an expression uses them directly (the check is case-insensitive), and names with a dot or other special characters. See the list of reserved words.

public IReadOnlyDictionary<string, string>? ExpressionAttributeNames { get; init; }

Property Value

IReadOnlyDictionary<string, string>

ExpressionAttributeValues

Gets the substitutions for :value placeholders in the update and condition expressions. A placeholder that no expression uses, or that no value defines, makes DynamoDB reject the request.

public IReadOnlyDictionary<string, AttributeValue>? ExpressionAttributeValues { get; init; }

Property Value

IReadOnlyDictionary<string, AttributeValue>

Key

Gets the full primary key of the item: the partition key and, if the table has one, the sort key. Key attributes cannot be updated.

public required IReadOnlyDictionary<string, AttributeValue> Key { get; init; }

Property Value

IReadOnlyDictionary<string, AttributeValue>

ReturnConsumedCapacity

Gets whether to report consumed capacity in ConsumedCapacity.

public ReturnConsumedCapacity ReturnConsumedCapacity { get; init; }

Property Value

ReturnConsumedCapacity

ReturnItemCollectionMetrics

Gets whether to report the size of the item collection in ItemCollectionMetrics. Only tables with a local secondary index have item collections.

public ReturnItemCollectionMetrics ReturnItemCollectionMetrics { get; init; }

Property Value

ReturnItemCollectionMetrics

ReturnValues

Gets what to return in Attributes. The default returns nothing. There is no extra cost and the values are strongly consistent.

public ReturnValue ReturnValues { get; init; }

Property Value

ReturnValue

ReturnValuesOnConditionCheckFailure

Gets whether a failed condition returns the existing item in Item.

public ReturnValuesOnConditionCheckFailure ReturnValuesOnConditionCheckFailure { get; init; }

Property Value

ReturnValuesOnConditionCheckFailure

TableName

Gets the table name (or table ARN).

public required string TableName { get; init; }

Property Value

string

UpdateExpression

Gets the actions to apply, in up to four clauses that may each appear once and be combined, for example "SET #n = :name, visits = visits + :one REMOVE tempFlag ADD tags :newTags". An attribute path can appear in only one action. The expression can be at most 4 KB. Attribute names that are DynamoDB reserved words, such as name, status, size, order or total, must be aliased with a #placeholder defined in ExpressionAttributeNames; written directly, DynamoDB rejects the request with a ValidationException. See the list of reserved words.

public string? UpdateExpression { get; init; }

Property Value

string

Remarks

  • SET assigns values, replacing existing ones. It can compute, for example a = a + :n, b = if_not_exists(b, :zero) or list = list_append(list, :more), and it works on nested paths such as address.city or items[2].
  • REMOVE deletes attributes, or elements of a list.
  • ADD adds a number to a number attribute (a missing attribute counts as 0, which makes it an atomic counter) or elements to a set. It only works on top-level attributes.
  • DELETE removes elements from a set. It only works on top-level attributes.

The result of the update must not make the item larger than 400 KB. Values are written as placeholders (:name) defined in ExpressionAttributeValues.

Methods

Equals(UpdateItemRequest?)

public bool Equals(UpdateItemRequest? other)

Parameters

other UpdateItemRequest

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

Operators

operator ==(UpdateItemRequest?, UpdateItemRequest?)

public static bool operator ==(UpdateItemRequest? left, UpdateItemRequest? right)

Parameters

left UpdateItemRequest
right UpdateItemRequest

Returns

bool

operator !=(UpdateItemRequest?, UpdateItemRequest?)

public static bool operator !=(UpdateItemRequest? left, UpdateItemRequest? right)

Parameters

left UpdateItemRequest
right UpdateItemRequest

Returns

bool