diff --git a/app/org/elastic4play/models/ModelDef.scala b/app/org/elastic4play/models/ModelDef.scala index 67de6a7..7f2a0bc 100644 --- a/app/org/elastic4play/models/ModelDef.scala +++ b/app/org/elastic4play/models/ModelDef.scala @@ -108,12 +108,14 @@ class BaseEntity(val model: BaseModelDef, val attributes: JsObject) { private final def removeProtectedAttributes(attrs: JsObject) = JsObject { attrs.fields .map { case (name, value) ⇒ (name, value, model.attributes.find(_.attributeName == name)) } - .collect { case (name, value, Some(desc)) if !desc.isSensitive ⇒ name → value } + .collect { + case (name, value, Some(desc)) if !desc.isSensitive ⇒ name → value + case (name, value, _) if name.startsWith("_") ⇒ name → value + } } def toJson = removeProtectedAttributes(attributes) + - ("id" → JsString(id)) + - ("_type" → JsString(model.modelName)) + ("id" → JsString(id)) /* compute auxiliary data */ override def toString = Json.prettyPrint(toJson) diff --git a/app/org/elastic4play/services/AuxSrv.scala b/app/org/elastic4play/services/AuxSrv.scala index b2d7eec..414a875 100644 --- a/app/org/elastic4play/services/AuxSrv.scala +++ b/app/org/elastic4play/services/AuxSrv.scala @@ -30,7 +30,10 @@ class AuxSrv @Inject() ( JsObject( entity.attributes.fields .map { case (name, value) ⇒ (name, value, entity.model.attributes.find(_.attributeName == name)) } - .collect { case (name, value, Some(desc)) if !desc.options.contains(AttributeOption.unaudited) ⇒ name → value }) + + .collect { + case (name, value, Some(desc)) if !desc.options.contains(AttributeOption.unaudited) ⇒ name → value + case (name, value, _) if name.startsWith("_") ⇒ name → value + }) + ("id" → JsString(entity.id)) + ("_type" → JsString(entity.model.modelName)) }