fun insert(categoryName: String) {
viewModelScope.launch {
val category =
CategoryData(0,
categoryName,
System.currentTimeMillis(),
System.currentTimeMillis())
AppDatabase.getCategoryDao(getApplication()).insert(category)
Log.d("CategoryViewModel", "insert :$category")
}
}
fun getAll(): Flow<List<CategoryData>> {
return AppDatabase.getCategoryDao(getApplication())
.getAll()
.catch { e -> e.printStackTrace() }
.flowOn(Dispatchers.IO)
}