Search code examples
liftlift-record

Given a Field and a Record, how to obtain the value of that Field within that Record?


I have something like:

val jobs = Job.where(...).fetch()
val fieldsToDisplay = Seq(Job.status, Job._id, ...)
val header = fieldsToDisplay map { _.name }
val tbl = jobs map { j => fieldsToDisplay map { _.getValueIn(j) } }
renderTable(header, tbl)

...and it's that hypothetical getValueIn I'm looking for.

I've been unable to find anything, but perhaps more experienced Lift'ers know a trick.


Solution

  • Each Field has a name that is unique within the Record

    jobs map { j => 
      fieldsToDisplay map { f => 
        j.fieldByName(f.name) 
      } 
    }