You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actually, searching in documentation, I found a simple example of update, just only "replace" old value by new value.
import { generateClient } from 'aws-amplify/data';
import { type Schema } from '../amplify/data/resource';
const client = generateClient<Schema>();
const todo = {
id: 'some_id',
content: 'Updated content',
};
const { data: updatedTodo, errors } = await client.models.Todo.update(todo);
But my use case is a increment, because i need to update column like views or counter in post. I understand that i can first to use "client.models.Blog.get" and after to use "client.models.Blog.update". But then is needed to perfom both requests for to update one simple "Atomic counters" in DynamoDB ?
Please if you face use case, recommend me, thanks.
Hi @jaimeardp in order to implement an atomic counter with Amplify Gen 2, I would recommend adding a custom mutation to your schema and execute the DynamoDB operation in an AppSync JS resolver.
Amplify CLI Version
10.8.1
Question
Environment information
Actually, searching in documentation, I found a simple example of update, just only "replace" old value by new value.
But my use case is a increment, because i need to update column like views or counter in post. I understand that i can first to use "client.models.Blog.get" and after to use "client.models.Blog.update". But then is needed to perfom both requests for to update one simple "Atomic counters" in DynamoDB ?
Please if you face use case, recommend me, thanks.
I hope this in amplify gen2 data client.
json file
The text was updated successfully, but these errors were encountered: