Using Waterline ORM from SailsJS, my defaults for autoCreatedAt
and autoUpdatedAt
are set to false, but I still need to implement to the functionality just using different field names (DBA request). Is there a way to either:
created_ts
and updated_ts
to be updated with triggers in the DB schema itself (but I still need Waterline to read them)?Thanks in advance.
I just opened two pull requests to implement this feature;
You can also follow this issue.
With this merged, in your model, instead of having for example :
autoCreatedAt: false,
autoUpdatedAt: false,
attributes: {
creationDate: {
columnName: 'created_ts',
type: 'datetime',
defaultsTo: function() {return new Date();}
},
updateDate: {
columnName: 'updated_ts',
type: 'datetime',
defaultsTo: function() {return new Date();}
}
},
beforeUpdate:function(values,next) {
values.updateDate = new Date();
next();
}
You can just do :
autoCreatedAt: 'created_ts',
autoUpdatedAt: 'updated_ts'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With