I am using sails 0.12.0 with sails-mongo 0.12.3. I took over an existing application from "external" developers.
I noticed that the "createdAt" date in present all mongo collections is incorrect, whereas the updatedAt date is correct. The createdAt date should auto-generate as today's date and time when the document is created, however it seems to be set to some date in the past. The updatedAt date does appear to have the correct value for today's date.
Example:
"createdAt" : ISODate("2017-09-25T18:39:49.409Z"), "updatedAt" : ISODate("2017-09-25T18:39:59.021Z")
How can I resolve this issue? I noticed that the files in the "models" directory are all empty, so it does not appear to be a model issue as no explicit models exist.
Example:
module.exports = {
attributes: {
}
};
I tried explicitly setting the createdAt date in one of the model files (as suggested by similar questions) however that did not work.
Example:
attributes: {
createdAt: {
type: 'datetime',
defaultsTo: function() {return new Date();}
}
},