Store createdAt and updateAt as Unix timestamps?
See original GitHub issueHello. I want to propose this feature. I’ve read docs and wasn’t able to find how to do this. At my company, we store all dates as unix timestamps, which is very useful.
What do you think? I cat implement this and open a pull request.
I think we can extend timestamps to:
var thingSchema = new Schema(
{..},
{
timestamps: {
createdAt: 'created_at',
fieldType: Number,
dateFunc: function () {
return Math.round(new Date().getTime()/1000); /* timestamp in seconds */
}
}
}
);
where: fieldType - type of the timestamps’ fields dateFunc - custom function to create date (we store dates in seconds, but new Date().getTime() returns milliseconds)
Issue Analytics
- State:
- Created 8 years ago
- Reactions:5
- Comments:14 (2 by maintainers)
Top Results From Across the Web
Store createAt and updatedAt as epoch unix timestamps ...
The timestamp stored in postgres is just another representation of the same information as the number of milliseconds since epoch time.
Read more >L5.2 unix timestamp on created_at and updated_at - Laracasts
In order to use date filtering in Algolia I need to set my dates as unix ... The ´´´$table->timestamps();´´´ creates both a created_at...
Read more >Store createAt and updatedAt as epoch unix timestamps ...
The timestamp stored in postgres is just another representation of the same information as the number of milliseconds since epoch time.
Read more >Mongoose Timestamps - Mastering JS
Mongoose has a built-in timestamps option that sets `createdAt` and `updatedAt` on your documents automatically. Here's how you can use it.
Read more >Mongoose Timestamps
const userSchema = new Schema({ name: String }, { timestamps: { createdAt: 'created_at', // Use `created_at` to store the created date updatedAt: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@SwapnilSoni1999 not currently.
@SwapnilSoni1999 yep it is released in 5.9.0, see timestamps docs for an example.