vogels
vogels copied to clipboard
schema.timestamp flexibility
Would be nice to be able to be able to customize createdAt and updatedAt format simply.
The point being to allow user to choose their format according to their need knowing that numeric has faster comparison and better compression and String is usually more readable (if using decent formatting like ISOString).
current definition is:
timestamp: true
we could keep the true with it default toISOString() behavior, and add possibility to define a function:
timestamp: function(date) {
// return desired format
return date.toISOString(); // timezone, current default
}
Here is a list of example:
return date.getTime(); // timestamp in ms
return date.getTime() / 1000; // timestamp in s
return parseInt(d.toISOString().split('T')[0].replace(/-/g, '')); // readable int, yyyymmdd
// etc ...
With this commit you can change the schema property from timestamps: true,
to:
timestamps: function () {
return Date.now();
},
or something like:
timestamps: function () {
return Math.floor(Date.now() / 1000);
},
Does it also work for 'updatedAt' ?
@osi-bhushankumar: Yes.
@Incubatio please, don't close this issue. It is not merged yet. Pull Request #99
@ryanfitz Any idea when we can have a similar feature officially supported?
This project is not maintained. The last commits are from Jan 13, 2016. @ryanfitz is nowhere to be found.
You can checkout the projects Dynogels (fork of Vogels) or Dynamoose.