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

DefaultModel CreatedAt and UpdatedAt fields saving wrong time on native methods #12

Closed
Elcomerz opened this issue Jun 12, 2020 · 1 comment
Assignees

Comments

@Elcomerz
Copy link

Elcomerz commented Jun 12, 2020

Describe the bug

To Reproduce
Steps to reproduce the behaviour:

  1. Declare a model with DefaultModel
    type Book struct {
    // DefaultModel add _id,created_at and updated_at fields to the Model
    mgm.DefaultModel bson:",inline"
    Name string json:"name" bson:"name"
    Pages int json:"pages" bson:"pages"
    }

  2. Insert a document to the DB using this model with Collection.InsertOne or Collection.InsertMany functions

3 Check created_at value of the inserted document

4.Its written as 0001-01-01T00:00:00.000+00:00

Expected behaviour
It should actually write 2020-06-12T05:45:56.598+00:00

Environment (please complete the following information):

  • OS: [ubuntu 18.04]
@Elcomerz Elcomerz changed the title DefaultModel CreatedAt and UpdatedAt fields saving wrong time value instead of actual one. DefaultModel CreatedAt and UpdatedAt fields saving wrong time value instead of actual one when creating documents with InsertOne and InsertMany functions Jun 12, 2020
@Elcomerz Elcomerz changed the title DefaultModel CreatedAt and UpdatedAt fields saving wrong time value instead of actual one when creating documents with InsertOne and InsertMany functions DefaultModel CreatedAt and UpdatedAt fields saving wrong time value when creating documents with InsertOne and InsertMany functions Jun 12, 2020
@mehran-prs
Copy link
Member

Mongo Go Models does not support webhook call on all of the collection methods.
Check mgm docs in README.md file please:

collection's methods which call to the hooks:
Create & CreateWithCtx
Update & UpdateWithCtx
Delete & DeleteWithCtx

@mehran-prs mehran-prs changed the title DefaultModel CreatedAt and UpdatedAt fields saving wrong time value when creating documents with InsertOne and InsertMany functions DefaultModel CreatedAt and UpdatedAt fields saving wrong time on native methods Jun 13, 2020
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