I've trouble dealing with a type: Date into SimpleSchema having a defaultValue.
In mongodb (3.0.1), the date entry have the time the meteor thread have been launch. The expected behaviour is to have "date" the insertion date of the object on the server.
lib/schema.js
Schema.DateCol = new SimpleSchema({
date: {
type: Date,
defaultValue: new Date()
},
dateModified: {
type: Date,
autoValue: function () { return new Date(); }
}
});
client/home.html
{{> quickForm id="test" schema="Schema.DateCol" collection="DateCol" type="insert" }}
Into the mongo, after inserting two objects:
- meteor thread launch at "Wed May 20 2015 12:28:42 GMT+0200 (CEST)"
- both objects have been inserted at one minute of interval: the first at "Wed May 20 2015 12:30:50 GMT+0200 (CEST)" and the second at "Wed May 20 2015 12:31:30 GMT+0200 (CEST)"
- the date field (defaultValue) for both object is: "Wed May 20 2015 12:28:42 GMT+0200 (CEST)"
Object 1
{
"_id": "PuME9jWwJJiw9diSC",
"date": new Date(1432117722634),
"dateModified": new Date(1432117850366)
}
Object 2:
{
"_id": "qqHqkN4YapWDsFhxx",
"date": new Date(1432117722634),
"dateModified": new Date(1432117890380)
}
You'll fin enclose a repository Github with the error, using MongoDB 3.0.1 (I haven't this error on MongoDB 2.4): https://github.com/JVercout/meteor-defaultValue-date-errored
Any ideas?