I am using Mongoose & Node.js for my webserver.
As a part of one of my document schemas, I have a 'timestamp' field.
The line for it in the schema is:
timestamp: { type: Date, default: Date.now }
This works fine, and allows me to retrieve documents based on the timestamp, however, this saves as the ISODate format as described here: http://docs.mongodb.org/manual/core/document/#date, like this:
"timestamp":"2013-04-04T19:31:38.514Z"
I don't mind this, but I send this to the client as is. This means I have to use Date.parse() at the client end before I can comparative operations with it.
Is there any way to either store the date as an integer, or automatically convert it to one when it's retrieved?
Is there any reason I should keep it how it is, and just deal with it at the client end?
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…