data class FavouriteEntity(
@PrimaryKey(autoGenerate = true)
val id : Int?,
@ColumnInfo(name = "user_id") var userId : String,
@ColumnInfo(name = "fav_restaurant_id") var favouriteRestaurantId : String,
@ColumnInfo(name = "fav_restaurant_name") var favouriteRestaurantName : String,
@ColumnInfo(name = "fav_restaurant_img") var favouriteRestaurantImage : String,
@ColumnInfo(name = "fav_restaurant_price") var favouriteRestaurantPrice : String,
@ColumnInfo(name = "fav_restaurant_rating") var favouriteRestaurantRating : String
)
以下是我的实体类。我希望主键自动递增。 但是当我创建一个该类的对象时,如下所示:
var favouriteEntity = FavouriteEntity(
userId,
restaurant.restaurantId,
restaurant.restaurantName,
restaurant.restaurantImageUrl,
restaurant.restaurantCostForOne,
restaurant.restaurantRating
)
我需要将一个整数作为ID传递。但我希望ID能够自动增长。请帮忙。