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

Support default fields and custom fields #62

Closed
jiangz222 opened this issue Aug 22, 2020 · 2 comments
Closed

Support default fields and custom fields #62

jiangz222 opened this issue Aug 22, 2020 · 2 comments
Labels
feature new feature

Comments

@jiangz222
Copy link
Collaborator

jiangz222 commented Aug 22, 2020

  • Default fields:
    Fields like CreateAt and UpdateAt, user doesn't need to operate those fileds when do insert or update operation
  • Custom fields:
    User can define their custom fields about create and update time, like Create_At, Update_At with different type like time.Time or int64
@jiangz222 jiangz222 added the feature new feature label Aug 22, 2020
@jiangz222 jiangz222 mentioned this issue Aug 22, 2020
@jiangz222
Copy link
Collaborator Author

jiangz222 commented Aug 31, 2020

  • Default filed was partially implement in Hooks #71 , fields CreateAt and UpdateAt can update as default fields by insert field.DefaultField in document struct:
field.DefaultField `bson:",inline"`
  • Custom field was partially implement in Hooks #71 too, user can define their custom fields about create and update time, with type time.Time or int64. You can check examples here:
func (u *UserHook) CustomFields() field.CustomFieldsBuilder {
	return field.NewCustom().SetCreateAt("CreateTimeAt").SetUpdateAt("UpdateTimeAt")
}
  • But, function about default or custom fields only work in insert operation (InsertOne/InsertMany). 😢
    More job need to do in update operation.

@jiangz222 jiangz222 changed the title Create and update some fields as default Support default fields and custom fields Aug 31, 2020
This was referenced Aug 31, 2020
@jiangz222
Copy link
Collaborator Author

#78 support this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature new feature
Projects
None yet
Development

No branches or pull requests

1 participant