Why is formatDates function not invoked?


I use this function in my model, but after tinkering with console.log, I think it isn’t even invoked.
I wonder where I do wrong?

  static formatDates(field, value) {

    if (field === 'period') {
      return value.format('YYYY-MM-DD');
    return super.formatDates(field, value);


Wait, I think I was missing the point in the docs. It is invoked when saving model, not when fetching.


Yup you must use castDates for that http://adonisjs.com/docs/4.0/lucid#_casting_dates