I want to delete all values inside one to many relationship
Parent Table :
@Entity(tableName = "Product")
data class Products (
@PrimaryKey(autoGenerate = false)
@ColumnInfo(name = "id") var id : Int = 0,
@ColumnInfo(name = "name")
var name : String? = null,
@ColumnInfo(name = "category_id")
var category_id : String? = null,
@ColumnInfo(name = "subcategory_id")
var subcategory_id : String? = null,
@ColumnInfo(name = "other_images")
var other_images: List<String> = listOf(),
@ColumnInfo(name = "price")
var price : String? = null,
@ColumnInfo(name = "variants")
var variants : List<Variants> = listOf()
)
Child Table :
@Entity(tableName = "Variant")
data class Variants (
@PrimaryKey(autoGenerate = false)
@ColumnInfo(name = "id")
var id : Int = 0,
@ColumnInfo(name = "product_id")
var product_id : String? = null,
@ColumnInfo(name = "price")
var price : String? = null,
@ColumnInfo(name = "discounted_price")
var discounted_price : String? = null,
@ColumnInfo(name = "image")
var image : String? = null,
@ColumnInfo(name = "moq")
var moq : String? = null,
@ColumnInfo(name = "cart_count")
var cart_count : String? = null,
@ColumnInfo(name = "is_notify_me")
var is_notify_me : Boolean? = null
)
Relationship :
data class ProductWithVariants(
@Embedded val product: Products,
@Relation(
parentColumn = "id",
entityColumn = "id"
)
val variants: MutableList<Variants>
)
Simply.. i want to delete all products and variants , Delete Single Product with corresponding variants and Update Single Product
Any changes in relationship ?? and i also need queries in dao !!