Legacy 4.1 Creating a new BaseModel that extends Model - then trying to use Traits #4168
-
Hello We're using AdonisJS Legacy 4.1 and have in the past been using Models as : Model We're wanting to output ALL dates from our Models as ISO formatted ("YYYY-MM-DDThh:mm:ssZ") as opposed to the default "YYYY-MM-DD hh:mm:ss". As such, rather than adding the following to every Model
I figured i'd add it once to a new Model called "BaseModel" as
My plan then is to alter all of our Models to Extend "BaseModal" rather than "Model". The structure is now This works a treat when reading models, but when we apply a Trait to one of our leaf level Models (and not all use it), it's not working! I assume that I need to add something to BaseModel to pass that upwards through to Model? The examples in the documentation don't cover this hierarchy. Please can someone help? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Closing... Realised the issue was simply that my BaseModel didn't have defaults for the createdAtColumn and updatedAtColumn - out child Models have optional traits applied that change the columns to match CREATED_DATE and UPDATED_DATE respectively.
|
Beta Was this translation helpful? Give feedback.
Closing... Realised the issue was simply that my BaseModel didn't have defaults for the createdAtColumn and updatedAtColumn - out child Models have optional traits applied that change the columns to match CREATED_DATE and UPDATED_DATE respectively.