I am attempting to model an existing MSSQL table in SailsJS. Unsurprisingly the tables in the existing database have a createdAt and updatedAt column similar to what is generated by the SailsJS framework.
Is there a way to assign the value of the property generated by the SailsJS framework to an attribute that I have defined? For example:
attributes: {
...
creationDate:{
columnName:'cre_dt',
type:'datetime',
defaultsTo: this.createdAt
}
...
}
You could remap the following way:
Now it's possible to use the
autoCreatedAt
andautoUpdatedAt
to set a custom name for these fields as described at http://sailsjs.com/documentation/concepts/models-and-orm/model-settings#?autocreatedatNo, but you can turn off the auto-generated property entirely and use your own:
See the Waterline options doc.