Attribute Casting

Is there any options for a convenient method of converting attributes to the common data type.

You can use Moment.js which is used internally (by default) by AdonisJs.
You can check this post even if in your case you do not need to use Moment.js under that specific circumstance: Moment JS in Adonis Framework

How about the array/json field. I think Moment.js only for the date-time

  "id": 1,
  "username": "",
  "email": "",
  "roles": [
      "id": 2,
      "name": "Singer",
      "permissions": "{\"userCreate\": false, \"userUpdate\": true, \"userView\": true, \"userDelete\": false}",
      "pivot": {
        "role_id": 2,
        "user_id": 1

I want to convert field permissions into JSON

I found the solution adonis-jsonable
maybe adonis should have some official package like this

1 Like