F
F
foonfyrick2021-02-12 18:37:46
Android
foonfyrick, 2021-02-12 18:37:46

How to get 2 Dao for DB correctly?

I have IDao - this is an interface that contains methods for working with one of the tables, and DaoTransaction is an abstract class, in it I made a function in which 2 methods of inserting into the database are executed at once, so that, in case of an incorrect insertion into one of tables, none of the insertion methods worked, most likely I did everything wrong, tell me how best to do it?
I did like this:

abstract fun getDao():DaoTransaction
    abstract fun getIDao():IDao

    operator fun component1():DaoTransaction?=getDao()
    operator fun component2():IDao?=getIDao()

val (dao,iDao) = MyDatabase.getInstance(app)!!.also {
            it.getIDao()
            it.getDao()
        }
        repository = MyRepository(dao,iDao)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question