File tree Expand file tree Collapse file tree 1 file changed +12
-20
lines changed
daprdocs/content/en/developing-applications/building-blocks/state-management Expand file tree Collapse file tree 1 file changed +12
-20
lines changed Original file line number Diff line number Diff line change @@ -181,28 +181,20 @@ DAPR_STORE_NAME = "statestore"
181181async def main():
182182 client = DaprClient()
183183
184- # Define the first state operation to save the value "2"
185- op1 = StateItem(
186- key="key1",
187- value=b"2"
184+ client.execute_state_transaction(
185+ store_name=DAPR_STORE_NAME,
186+ operations=[
187+ # Define the first state operation to save the value "2"
188+ TransactionalStateOperation(
189+ key='key1', data='2', metadata={'outbox.projection': 'false'}
190+ ),
191+ # Define the second state operation to publish the value "3" with metadata
192+ TransactionalStateOperation(
193+ key='key1', data='3', metadata={'outbox.projection': 'true'}
194+ ),
195+ ],
188196 )
189197
190- # Define the second state operation to publish the value "3" with metadata
191- op2 = StateItem(
192- key="key1",
193- value=b"3",
194- options=StateOptions(
195- metadata={
196- "outbox.projection": "true"
197- }
198- )
199- )
200-
201- # Create the list of state operations
202- ops = [op1, op2]
203-
204- # Execute the state transaction
205- await client.state.transaction(DAPR_STORE_NAME, operations=ops)
206198 print("State transaction executed.")
207199` ` `
208200
You can’t perform that action at this time.
0 commit comments