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

Best way to add a createdAt timestamp? #472

Open
ilias-t opened this issue Aug 15, 2023 · 1 comment
Open

Best way to add a createdAt timestamp? #472

ilias-t opened this issue Aug 15, 2023 · 1 comment

Comments

@ilias-t
Copy link

ilias-t commented Aug 15, 2023

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [x] question about how to use this project

  • Summary
    What's the recommended way to add timestamps to Session documents? I'm looking for something similar to this behavior in mongoose. My naive approach would be to use the serialize hook to add a createdAt property there. If that's the best way it could be nice to have a more declarative way to add this field.

@CarlosLunaGit
Copy link

Hello @ilias-t I took a look into the projects file since I have the same feeling that having some timestamps maybe of use. At first glance it seems the InternalSessionType should be extended with that property createdAt then on session object creation it should be initialized right before removing the lastModified prop from the session object before update.

Rephrasing your mongoose reference maybe we are shooting for something like:

...connect-mongo will then set createdAt when the document is first inserted (create event fires), and update updatedAt whenever you update the document (update/set events fire).

Sending a forked tryout to discuss further this idea.

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

No branches or pull requests

2 participants