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

Add fuction database update tool to extract sql tag #41

Merged
merged 3 commits into from
Jun 19, 2024

Conversation

harissudrajat
Copy link
Contributor

This function used for extract the column name on struct tag sql with prefix column:

type Model struct {
	ID      int    `sql:"column:id;" json:"id"`
	Name    string `sql:"column:name;" json:"name"`
	Address string `sql:"column:address" json:"address"`
}

type Repository interface {
	Update(ctx context.Context, data *Model) error
}

type sqlRepo struct {
	updateTool *DBUpdateTools
}

func NewSQLRepo() Repository {
	return &sqlRepo{
		updateTool: &DBUpdateTools{
			KeyExtractorFunc: DBUpdateSqlExtractorKey,
		},
	}
}

func (s *sqlRepo) Update(ctx context.Context, data *Model) error {

	data = &Model{
		ID:      1,
		Name:    "John",
		Address: "Indonesia",
	}

	updated := s.updateTool.ToMap(data)

	return nil
}

@harissudrajat harissudrajat requested a review from a team as a code owner June 2, 2024 16:38
Copy link

codecov bot commented Jun 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 22.88%. Comparing base (f9dba3e) to head (be9204e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #41      +/-   ##
==========================================
+ Coverage   22.72%   22.88%   +0.15%     
==========================================
  Files          43       43              
  Lines        2477     2482       +5     
==========================================
+ Hits          563      568       +5     
  Misses       1890     1890              
  Partials       24       24              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@agungdwiprasetyo agungdwiprasetyo merged commit aeccc2e into golangid:master Jun 19, 2024
3 checks passed
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.

2 participants