I'm working on dictionnary application in which the api request have many nested lists , i have tried to insert all the nested lists but i'm getting different error each time , i would like to know what is the best way to save multiple nested lists , should i use room relations or something else , thank you in advance for help , i m really stuck with this for few days now
- This is sample schema of how are the lists nested
- This is the parent list
@Entity(tableName = "DICTIONNARYTABLE")
@TypeConverters(DictionnaryModelConverter::class)
class DictionnaryModel : ArrayList<DictionnaryModelItem>() {
@PrimaryKey(autoGenerate = true)
@NotNull
val wordId: Long = 0
}
- The parent list has two lists as well
@Entity
data class DictionnaryModelItem(
@PrimaryKey val dictionnaryModelId: Long = 0,
@TypeConverters(DictionnaryMeaningConverter::class)
val meanings: MutableList<Meaning>,
@TypeConverters(DictionnaryPhoneticsConverter::class)
val phonetics: MutableList<Phonetic>,
val word: String
)
//---------------------------
@Entity
data class Meaning(
@PrimaryKey val meaningId: Long = 0,
@TypeConverters(DictionnaryDefinitionConverter::class)
val definitions: List<Definition>,
val partOfSpeech: String
)
///-------------------------------
@Entity
data class Phonetic(
@PrimaryKey val phoneticId: Long = 0,
val audio: String,
val text: String
)
- inside the meaning , i also have definition which another model
@Entity
data class Definition(
@PrimaryKey val definitionId: Long = 0,
val definition: String,
val example: String,
@TypeConverters(DictionnarySynonymsConverter::class)
val synonyms: List<String>
)