Skip to content

schema.timestamp flexibility #86

@Incubatio

Description

@Incubatio

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 ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions