question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] Timestamps should be customizable to use JSON date instead of epoch

See original GitHub issue

Summary:

The automatic timestamps is a nice feature, but it would be nice if you could use another format such as JSON dates.

Suggestion for an extension to the options to allow for custom formatting:

{
  timestamps: {
    createdAt: 'createdTime',
    updatedAt: 'modifiedTime',
    format: ms => new Date(ms).toJSON()
  },
}

For even simpler configuration, the type of format could be e.g. "ms" | "json" | (ms: number) => any, so that you could use format: 'json'

Code sample:

Schema

// Code here

Model

// Code here

General

// Code here

Environment:

Operating System: Ubuntu Operating System Version: 18.04 Node.js version (node -v): 14.2.0 NPM version: (npm -v): 6.14.4 Dynamoose version: 2.7.3

Other information (if applicable):

Other:

  • I have read through the Dynamoose documentation before posting this issue
  • I have searched through the GitHub issues (including closed issues) and pull requests to ensure this feature has not already been suggested before
  • I have filled out all fields above
  • I am running the latest version of Dynamoose

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
khanghua1505commented, May 13, 2022

I have the same issue. I use AWS amplify to generate the data models. In my bussiness logic, I must create the custom mutations or queries, I use lambda as datasources. The amplify use ISO string for AWSDateTime. In my solution, Insteads Date, I use String and convert String to Date. I hope the dynamoose can be custom the timestamps.

1reaction
fishcharliecommented, Mar 26, 2021

@henhal Totally fair. Appreciate the discussion. Just to be clear and make sure I understand, this is primarily for viewing the data in the DynamoDB Console or other 3rd party tools, correct? Because within your application you can easily do toJSON as you mentioned. So that is why I was misunderstanding the use case here. It’s specifically related to viewing the raw data?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the "right" JSON date format? - Stack Overflow
I would use a format that can be easily converted to a Date object in JavaScript, i.e. one that can be passed to...
Read more >
Timestamps, Time Zones, Time Ranges, and Date Formats
The timestamp is parsed either using the default timestamp parsing settings, or a custom format that you specify, including the time zone. When...
Read more >
Demystifying DateTime Manipulation in JavaScript - Toptal
Here we will explore some of the key concepts that are necessary for manipulating date and time values correctly, formats that are convenient...
Read more >
Swift JSON Date Formatting - Tapadoo
The JSON date format for a Date got the value of 577814769.81546402 . This almost looks like a unix epoch timestamp, but if...
Read more >
Power BI - Convert Timestamp to Datetime - YouTube
Hi everybody! Parker here. Check out this quick tip on how to convert a Unix timestamp to datetime. Hope you enjoy!Enroll in my...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found