in lambda/go/add-podcasts/main.go [330:358]
func (h *Handler) updateEpisodeStatus(ctx context.Context, episode workshop.Episode) error {
log.Printf("updating episode %v with status, %v",
episode.ID, episode.Status)
exp, err := ddbexp.NewBuilder().WithUpdate(
ddbexp.Set(
ddbexp.Name("status"),
ddbexp.Value(episode.Status),
),
).Build()
if err != nil {
return fmt.Errorf("failed to build update expression, %w", err)
}
_, err = h.ddbClient.UpdateItem(ctx, &ddb.UpdateItemInput{
TableName: &h.episodeTableName,
Key: workshop.Episode{
ID: episode.ID,
}.AttributeValuePrimaryKey(),
UpdateExpression: exp.Update(),
ExpressionAttributeNames: exp.Names(),
ExpressionAttributeValues: exp.Values(),
})
if err != nil {
return fmt.Errorf("failed to update episode, %w", err)
}
return nil
}