code: func UpdateDevice(db sqlx.Execer, d *Device) error {
  	d.UpdatedAt = time.Now()
  	res, err := db.Exec(`
  		update device set
  			updated_at = $2,
  			device_profile_id = $3,
  			service_profile_id = $4,
  			routing_profile_id = $5,
  			skip_fcnt_check = $6,
  			reference_altitude = $7,
  			mode = $8
  		where
  			dev_eui = $1`,
  		d.DevEUI[:],
  		d.UpdatedAt,
  		d.DeviceProfileID,
  		d.ServiceProfileID,
  		d.RoutingProfileID,
  		d.SkipFCntCheck,
  		d.ReferenceAltitude,
  		d.Mode,
  	)
  	if err != nil {
  		return handlePSQLError(err, "update error")
  	}
  	ra, err := res.RowsAffected()
  	if err != nil {
  		return handlePSQLError(err, "get rows affected error")
  	}
  	if ra == 0 {
  		return ErrDoesNotExist
  	}
  
  	log.WithField("dev_eui", d.DevEUI).Info("device updated")
  	return nil
  }
docs: // UpdateDevice updates the given device.