I'm trying to append a new string into my "savedPosts" array and my first attempt was to read the previous data, then append the new element and finally update. Although after checking documentation, it says that I can skip the reading step and update my existing list with one call.
My code so far:
await UserModel.update({
awsCognitoId: req.user,
savedPosts: {$add: postId}
});
Error:
{
"code": "ValidationException",
"message": "Invalid UpdateExpression: Incorrect operand type for operator or function; operator: ADD, operand type: STRING, typeSet: ALLOWED_FOR_ADD_OPERAND"
}