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

Ability to set custom createdAt/updatedAt on create #520

Merged
merged 6 commits into from Jun 19, 2018

Conversation

@MihaelIsaev
Copy link
Member

MihaelIsaev commented Jun 19, 2018

When I'm trying to seed my database I want to be able to set createdAt / updatedAt fields with custom values.
This commit allows to do that.

Ability to set custom createdAt/updatedAt on create
When I'm trying to seed my database I want to be able to set `createdAt` / `updatedAt` fields with custom values.
This commit allows to do that.
// set timestamps
copy = model
let now = Date()
copy.fluentUpdatedAt = now

This comment has been minimized.

@tanner0101

tanner0101 Jun 19, 2018

Member

No reason to set the model's existing property on the copy, it will already be there. Just check here if fluentUpdatedAt is nil before setting (same for fluentCreatedAt)

MihaelIsaev added some commits Jun 19, 2018

var copy = model

// set timestamps
if Result.createdAtKey != nil || Result.createdAtKey != nil {

This comment has been minimized.

@ezfe

ezfe Jun 19, 2018

This looks like you meant

Result.createdAtKey != nil || Result.updatedAtKey != nil

This comment has been minimized.

@MihaelIsaev

MihaelIsaev Jun 19, 2018

Author Member

got it!

MihaelIsaev and others added some commits Jun 19, 2018

@tanner0101 tanner0101 added this to the 3.0.0-rc.4 milestone Jun 19, 2018

@tanner0101 tanner0101 merged commit a821d46 into vapor:master Jun 19, 2018

0 of 5 checks passed

ci/circleci: linux Your tests are queued behind your running builds
Details
ci/circleci: linux-mysql Your tests are queued behind your running builds
Details
ci/circleci: linux-postgresql Your tests are queued behind your running builds
Details
ci/circleci: linux-release Your tests are queued behind your running builds
Details
ci/circleci: linux-sqlite Your tests are queued behind your running builds
Details
@penny-coin

This comment has been minimized.

Copy link

penny-coin commented Jun 19, 2018

Hey @MihaelIsaev, you just merged a pull request, have a coin!

You now have 51 coins.

@tanner0101 tanner0101 self-assigned this Jun 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment