title: Conceptually, how do I do a simple Read/Update cycle using LiveData and Room?
body: <p>In a Repository class (see: <a href="https://developer.android.com/jetpack/docs/guide" rel="nofollow noreferrer">https://developer.android.com/jetpack/docs/guide</a>), I'm trying to:</p>
  
  <p>1) Read a value from the Room DB</p>
  
  <p>2) Increment the value</p>
  
  <p>3) Write the value back out through the appDao to Room.</p>
  
  <p>I'm pretty sure I can solve this at the Dao level, ie in a Transaction or something, but I'm not sure if that's the right approach.  It seems like a pretty simple use case, and the solutions I've come up with seem way more complicated than necessary.  I'm wondering if my tenuous handle on Kotlin coroutines is holding me back here.</p>
  
  <pre><code>
  /* Repository Class*/
  
  fun getCurrentAlarmTime():LiveData&lt;Calendar&gt; {
          return Transformations.map(appDao.getProfileData(currentAlarmTime)){ nullableProfileData -&gt;
             if (nullableProfileData == null) {
                 defaultAlarmTime
             } else {
                 nullableProfileData.value.toLongOrNull()?.let { millis -&gt;
                     getCalendar(millis)
                 }
             }
          }
      }
  
  fun setCurrentAlarmTime(calendar:Calendar) {
          GlobalScope.launch {
              appDao.setProfileData(
                  ProfileData(
                      currentAlarmTime,
                      calendar.timeInMillis.toString()
                  )
              )
          }
      }
  
  fun incrementAlarmTimeBy1Hour() {
  // this is what I'm having a problem with, using the fns above.
  // I've got a pretty good handle on LiveData, 
  // Transformations, and MediatorLiveData, 
  // but I am still stuck.
  }
  
  Expected result would be that the time in the database is updated by 1 hour.
  </code></pre>