Struct aws_sdk_dynamodb::types::AttributeValueUpdate
source · #[non_exhaustive]pub struct AttributeValueUpdate {
pub value: Option<AttributeValue>,
pub action: Option<AttributeAction>,
}
Expand description
For the UpdateItem
operation, represents the attributes to be modified, the action to perform on each, and the new value for each.
You cannot use UpdateItem
to update any primary key attributes. Instead, you will need to delete the item, and then use PutItem
to create a new item with new attributes.
Attribute values cannot be null; string and binary type attributes must have lengths greater than zero; and set type attributes must not be empty. Requests with empty values will be rejected with a ValidationException
exception.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.value: Option<AttributeValue>
Represents the data for an attribute.
Each attribute value is described as a name-value pair. The name is the data type, and the value is the data itself.
For more information, see Data Types in the Amazon DynamoDB Developer Guide.
action: Option<AttributeAction>
Specifies how to perform the update. Valid values are PUT
(default), DELETE
, and ADD
. The behavior depends on whether the specified primary key already exists in the table.
If an item with the specified Key is found in the table:
-
PUT
- Adds the specified attribute to the item. If the attribute already exists, it is replaced by the new value. -
DELETE
- If no value is specified, the attribute and its value are removed from the item. The data type of the specified value must match the existing value's data type.If a set of values is specified, then those values are subtracted from the old set. For example, if the attribute value was the set
\[a,b,c\]
and theDELETE
action specified\[a,c\]
, then the final attribute value would be\[b\]
. Specifying an empty set is an error. -
ADD
- If the attribute does not already exist, then the attribute and its values are added to the item. If the attribute does exist, then the behavior ofADD
depends on the data type of the attribute:-
If the existing attribute is a number, and if
Value
is also a number, then theValue
is mathematically added to the existing attribute. IfValue
is a negative number, then it is subtracted from the existing attribute.If you use
ADD
to increment or decrement a number value for an item that doesn't exist before the update, DynamoDB uses 0 as the initial value.In addition, if you use
ADD
to update an existing item, and intend to increment or decrement an attribute value which does not yet exist, DynamoDB uses0
as the initial value. For example, suppose that the item you want to update does not yet have an attribute named itemcount, but you decide toADD
the number3
to this attribute anyway, even though it currently does not exist. DynamoDB will create the itemcount attribute, set its initial value to0
, and finally add3
to it. The result will be a new itemcount attribute in the item, with a value of3
. -
If the existing data type is a set, and if the
Value
is also a set, then theValue
is added to the existing set. (This is a set operation, not mathematical addition.) For example, if the attribute value was the set\[1,2\]
, and theADD
action specified\[3\]
, then the final attribute value would be\[1,2,3\]
. An error occurs if an Add action is specified for a set attribute and the attribute type specified does not match the existing set type.Both sets must have the same primitive data type. For example, if the existing data type is a set of strings, the
Value
must also be a set of strings. The same holds true for number sets and binary sets.
This action is only valid for an existing attribute whose data type is number or is a set. Do not use
ADD
for any other data types. -
If no item with the specified Key is found:
-
PUT
- DynamoDB creates a new item with the specified primary key, and then adds the attribute. -
DELETE
- Nothing happens; there is no attribute to delete. -
ADD
- DynamoDB creates a new item with the supplied primary key and number (or set) for the attribute value. The only data types allowed are number, number set, string set or binary set.
Implementations§
source§impl AttributeValueUpdate
impl AttributeValueUpdate
sourcepub fn value(&self) -> Option<&AttributeValue>
pub fn value(&self) -> Option<&AttributeValue>
Represents the data for an attribute.
Each attribute value is described as a name-value pair. The name is the data type, and the value is the data itself.
For more information, see Data Types in the Amazon DynamoDB Developer Guide.
sourcepub fn action(&self) -> Option<&AttributeAction>
pub fn action(&self) -> Option<&AttributeAction>
Specifies how to perform the update. Valid values are PUT
(default), DELETE
, and ADD
. The behavior depends on whether the specified primary key already exists in the table.
If an item with the specified Key is found in the table:
-
PUT
- Adds the specified attribute to the item. If the attribute already exists, it is replaced by the new value. -
DELETE
- If no value is specified, the attribute and its value are removed from the item. The data type of the specified value must match the existing value's data type.If a set of values is specified, then those values are subtracted from the old set. For example, if the attribute value was the set
\[a,b,c\]
and theDELETE
action specified\[a,c\]
, then the final attribute value would be\[b\]
. Specifying an empty set is an error. -
ADD
- If the attribute does not already exist, then the attribute and its values are added to the item. If the attribute does exist, then the behavior ofADD
depends on the data type of the attribute:-
If the existing attribute is a number, and if
Value
is also a number, then theValue
is mathematically added to the existing attribute. IfValue
is a negative number, then it is subtracted from the existing attribute.If you use
ADD
to increment or decrement a number value for an item that doesn't exist before the update, DynamoDB uses 0 as the initial value.In addition, if you use
ADD
to update an existing item, and intend to increment or decrement an attribute value which does not yet exist, DynamoDB uses0
as the initial value. For example, suppose that the item you want to update does not yet have an attribute named itemcount, but you decide toADD
the number3
to this attribute anyway, even though it currently does not exist. DynamoDB will create the itemcount attribute, set its initial value to0
, and finally add3
to it. The result will be a new itemcount attribute in the item, with a value of3
. -
If the existing data type is a set, and if the
Value
is also a set, then theValue
is added to the existing set. (This is a set operation, not mathematical addition.) For example, if the attribute value was the set\[1,2\]
, and theADD
action specified\[3\]
, then the final attribute value would be\[1,2,3\]
. An error occurs if an Add action is specified for a set attribute and the attribute type specified does not match the existing set type.Both sets must have the same primitive data type. For example, if the existing data type is a set of strings, the
Value
must also be a set of strings. The same holds true for number sets and binary sets.
This action is only valid for an existing attribute whose data type is number or is a set. Do not use
ADD
for any other data types. -
If no item with the specified Key is found:
-
PUT
- DynamoDB creates a new item with the specified primary key, and then adds the attribute. -
DELETE
- Nothing happens; there is no attribute to delete. -
ADD
- DynamoDB creates a new item with the supplied primary key and number (or set) for the attribute value. The only data types allowed are number, number set, string set or binary set.
source§impl AttributeValueUpdate
impl AttributeValueUpdate
sourcepub fn builder() -> AttributeValueUpdateBuilder
pub fn builder() -> AttributeValueUpdateBuilder
Creates a new builder-style object to manufacture AttributeValueUpdate
.
Trait Implementations§
source§impl Clone for AttributeValueUpdate
impl Clone for AttributeValueUpdate
source§fn clone(&self) -> AttributeValueUpdate
fn clone(&self) -> AttributeValueUpdate
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for AttributeValueUpdate
impl Debug for AttributeValueUpdate
source§impl PartialEq for AttributeValueUpdate
impl PartialEq for AttributeValueUpdate
source§fn eq(&self, other: &AttributeValueUpdate) -> bool
fn eq(&self, other: &AttributeValueUpdate) -> bool
self
and other
values to be equal, and is used
by ==
.impl StructuralPartialEq for AttributeValueUpdate
Auto Trait Implementations§
impl Freeze for AttributeValueUpdate
impl RefUnwindSafe for AttributeValueUpdate
impl Send for AttributeValueUpdate
impl Sync for AttributeValueUpdate
impl Unpin for AttributeValueUpdate
impl UnwindSafe for AttributeValueUpdate
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute
] value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
[Quirk
] value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition
] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);