Hello all, I have a model in my android project that has a type converter of a custom class. My andr...
i
Hello all, I have a model in my android project that has a type converter of a custom class. My android project has a backend built on ktor. The ktor project also has a similar model and am using postress database for storage. The problem that i am facing is storing the type converted class inside my postgress alongside other attributes. Here is the models of the two. Thanks in advance. Android model
Copy code
@Entity(tableName = "requests")
public class Request extends BaseObservable implements Parcelable {
    @PrimaryKey(autoGenerate = true)
    private int request_id;// Document_id

    private String r_clients_id;
    private int r_tasker_id;
    private User user;// Type converter 
    private String requested_skill;
    private String time_stamp;
}
Same model for my ktor project
Copy code
class Request(
    val request_id: Int,

    val r_clients_id: Int,
    val r_tasker_id: Int,
    val user: User,
    val requested_skill: String,
    val time_stamp: String,
    val arrival_date: String,
): Serializable, Principal
Here is where am facing the challenge. I really don't know how to insert or reference the Type converter class in my object class.I am new to ktor and exposed.
Copy code
object Requests : Table() {
    val requestId: Column<Int> = integer("request_id").autoIncrement().primaryKey()
    val rClientId: Column<Int> = integer("r_clients_id").references(Users.userId)
    val rTaskerId: Column<Int> = integer("r_tasker_id").references(Taskers.taskerId)
    val user: Column<User> = ?????????????????????????

    val requestedSkill = varchar("requested_skill", 128)
    val timeStamp = varchar("time_stamp", 64)
    val arrivalDate = varchar("arrival_date", 64)
}
😇 2
t
How do you plan to store User in a table? As a text or as a related entity?
i
I want to store it as related entity
t
Than you need to create another table for User and link then with reference
i
Thanks @tapac. Am a novice in Expose any guide to a source that i would learn from.or an illustration to that?
t
i
Thanks for this