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

Allow override for createdAt and updatedAt properties #254

Merged
merged 2 commits into from
Jul 17, 2020
Merged

Allow override for createdAt and updatedAt properties #254

merged 2 commits into from
Jul 17, 2020

Conversation

azrikahar
Copy link
Contributor

@azrikahar azrikahar commented Jul 12, 2020

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Resolves: #252

This stems from the linked issue, but I did also thought about this a while ago when considering to retain the datetime if I'm migrating the posts to nuxt/content.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes (if not applicable, please state why)

I have mentioned that the createdAt and updatedAt properties can be overrided in the docs over here.

I'm not particular sure how we can add tests for this since the original createdAt & updatedAt of the files can be different if I make a new fork of the repo. With that said, I did do some tests myself and here are the test results:

value in content/document generated value when fetching
2019-02-10 2019-02-10T00:00:00.000Z
20x19-02-10 Falls back to original creation datetime
2019-02-10 10:00 2019-02-10T02:00:00.000Z
2019-02-10 10:00 PM 2019-02-10T14:00:00.000Z
Feb 2019 2019-01-31T16:00:00.000Z
2 2019 Falls back to original creation datetime

Note that my timezone is UTC +8, so there's 8 hours offset for the results with time.

@codecov-commenter
Copy link

codecov-commenter commented Jul 12, 2020

Codecov Report

❗ No coverage uploaded for pull request base (dev@be4e58c). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##             dev     #254   +/-   ##
======================================
  Coverage       ?   89.57%           
======================================
  Files          ?       15           
  Lines          ?      547           
  Branches       ?      116           
======================================
  Hits           ?      490           
  Misses         ?       50           
  Partials       ?        7           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be4e58c...cbc0068. Read the comment docs.

@atinux atinux self-requested a review July 15, 2020 17:10
@benjamincanac benjamincanac merged commit 4119c75 into nuxt:dev Jul 17, 2020
@benjamincanac
Copy link
Member

Thanks @azrikahar!

benjamincanac pushed a commit that referenced this pull request Jul 20, 2020
* feat: override createdAt & updatedAt if exists

* docs: mention createdAt & updatedAt override
benjamincanac pushed a commit that referenced this pull request Jul 27, 2020
* feat: override createdAt & updatedAt if exists

* docs: mention createdAt & updatedAt override
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Override createdAt and updatedAt
4 participants