0

I have a question lets say i have a record in this form:

case class BlahInfoRecord(
 id: Long,
 lvl: Int, /*possible values 1,2,3,4*/
 id1: Long,
 id2: Long,
 id3: Long,
 id4: Long,
 parentId: Long
)

and in schema I have

object blahSchema extends Schema {
  implicit object blahRecordKed extends KeyedEntityDef[BlahInfoRecord, Long] {
  def getId(ptInfo: BlahInfoRecord): Long = ptInfo.id
  def idPropertyName: String = "id"
  def isPersisted(blahInfo: BlahInfoRecord): Boolean = blahInfo.id > 0
}

val blahRecords: Table[BlahInfoRecord] =
    table[BlahInfoRecord]("blah_info")
}

I want to add method expansion like so:

def expansion(blahInfo: BlahInfoRecord): Query[BlahInfoRecord] = {
  from(blahRecords)(b => where(s"b.id${blahInfo.lvl} === ${blahInfo.id}") // essentially to get all records where id with index lvl is equal to a record id for example if i have blahRecord with lvl = 3 then i want this to translate to id3 === <id>
}

is it possible?

Алексей
  • 1,847
  • 12
  • 15

0 Answers0