Hi guys,
I am generating fixtures for tests and I want to MANUALLY set doc.createdAt
& doc.updatedAt
values - WITHOUT SimpleSchema doing its “autoValue”-thing.
My SimpleSchema is complex and has OTHER fields WITH autoValue-functions
that NEED to run when inserting, so I can NOT set getAutoValues
as suggested in the docs:
To skip adding automatic values, set the getAutoValues option to false when you call insert or update. This works only in server code.
This is how the field is defined in the schema:
// other fields with ``autoValue``-functions that NEED to run
// ..
// HOW TO SKIP autoValue ONLY for this field when inserting a doc?
updatedAt: {
type: Date,
autoValue: function() {
return new Date(); // always add date
},
},
Is there a way to achieve this? I guess I’ll have to hack the schema before the insert and reset it afterwards?