def update()

in app/data/Recipes.scala [79:109]


  def update(
      recipe: Recipe,
      description: Option[String],
      baseImage: BaseImage,
      diskSize: Option[Int],
      roles: List[CustomisedRole],
      modifiedBy: String,
      bakeSchedule: Option[BakeSchedule],
      encryptFor: List[AccountNumber]
  )(implicit dynamo: Dynamo): Either[DynamoReadError, Recipe] = {

    val baseUpdateExpr =
      set("baseImageId", baseImage.id) and
        set("roles", roles) and
        set("modifiedBy", modifiedBy) and
        set("modifiedAt", DateTime.now()) and
        (if (bakeSchedule.isDefined) set("bakeSchedule", bakeSchedule)
         else remove("bakeSchedule")) and
        (if (encryptFor.nonEmpty) set("encryptFor", encryptFor)
         else remove("encryptFor")) and
        (if (diskSize.isDefined) set("diskSize", diskSize)
         else remove("diskSize"))

    val updateExpr = description match {
      case Some(desc) => baseUpdateExpr and set("description", desc)
      case None       => baseUpdateExpr
    }

    val update = table.update("id" === recipe.id, updateExpr)
    update.exec().map(Recipe.db2domain(_, baseImage))
  }