Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema.timestamp flexibility #86

Open
Incubatio opened this issue Oct 31, 2015 · 6 comments
Open

schema.timestamp flexibility #86

Incubatio opened this issue Oct 31, 2015 · 6 comments
Labels

Comments

@Incubatio
Copy link

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 ...
@set-killer
Copy link

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);
}, 

@osi-bhushankumar
Copy link

Does it also work for 'updatedAt' ?

@set-killer
Copy link

@osi-bhushankumar: Yes.

@set-killer
Copy link

@Incubatio please, don't close this issue. It is not merged yet. Pull Request #99

@Incubatio Incubatio reopened this Jun 10, 2016
@sohailalam2
Copy link

@ryanfitz Any idea when we can have a similar feature officially supported?

@set-killer
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants