Can SerializeAs be a function? #3440
-
Can we call export default class User extends BaseModel {
@column({ serializeAs: () => ... })
public password: string
} https://docs.adonisjs.com/guides/models/serializing-models#hiding-properties |
Beta Was this translation helpful? Give feedback.
Answered by
thetutlage
Dec 27, 2021
Replies: 1 comment
-
You can define your own export default class User extends BaseModel {
public serializeAttributes() {
// your serialization logic
}
} Here is the default implementation https://github.com/adonisjs/lucid/blob/develop/src/Orm/BaseModel/index.ts#L1797 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
LeCoupa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can define your own
serializeAttributes
function on the model to customize the serialization behavior.Here is the default implementation https://github.com/adonisjs/lucid/blob/develop/src/Orm/BaseModel/index.ts#L1797