Salat - how to lookup remapped values from a context

93 views Asked by At

I'm stuck and in need of your help.

Assuming I have this context to work with the play framework:

    package object mongoContext {
  implicit val context = {
    val context = new Context {
      val name = "global"
      override val typeHintStrategy = StringTypeHintStrategy(when = TypeHintFrequency.WhenNecessary, typeHint = "_t")
    }
    context.registerGlobalKeyOverride(remapThis = "id", toThisInstead = "_id")
    context.registerClassLoader(Play.classloader)
    context
  }
}

How would one lookup dynamically what FieldName id is remapped to on the database side?

Thanks in advance

1

There are 1 answers

0
prasinous On BEST ANSWER

A field named "id" in your model object will be mapped to "_id" in the database.

As far as looking it up - ? in the Context - call

Context#determineFieldName(clazz: Class[_], fieldName: String)