Skip to content

Instantly share code, notes, and snippets.

@LukaKordic
Created August 13, 2019 11:35
Show Gist options
  • Save LukaKordic/ae2cfd086e0ad3dd47b7ceba7d765f90 to your computer and use it in GitHub Desktop.
Save LukaKordic/ae2cfd086e0ad3dd47b7ceba7d765f90 to your computer and use it in GitHub Desktop.
@Dao
interface WeatherDao {
@Transaction
suspend fun updateWeatherAndReturn(weather: WeatherEntity): WeatherEntity {
saveWeatherInfo(weather)
return getWeatherInfoForCity(weather.name ?: "")
}
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun saveWeatherInfo(weather: WeatherEntity)
@Query("SELECT * FROM $WEATHER_TABLE_NAME WHERE name = :city LIMIT 1")
suspend fun getWeatherInfoForCity(city: String): WeatherEntity
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment