GithubHelp home page GithubHelp logo

ahlib-db's Introduction

Introduction

Stars Earned Collaborated Stars Followers Repositories GitHub Page

  • ๐Ÿ‘‹ Hi! Here is AoiHosizora (้’ใ„ใปใ—ใžใ‚‰), majors in Intelligent Software and Robotics, Software Engineering.
  • ๐Ÿ“ Speaking languages: Mandarin Chinese (Native), Teo-Swa-uรช (Native), English (CET-6), Japanese (JLPT-N1).
  • ๐Ÿข Some owned GitHub organizations: ah-shellext & ah-forklib, my public email: [email protected].
  • ๐Ÿš€ Interest areas: distributed backend system development, desktop client and android client development.
  • โšก Favorite programming languages: Go, Dart, C#, Kotlin, Rust, Typescript, etc.

Coding status

ahlib-db's People

Contributors

aoi-hosizora avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

isgasho

ahlib-db's Issues

Change OrderByFunc signature to builtin type

func OrderByFunc(p xproperty.PropertyDict) func(source string) string
// PropertyMapperValue represents a value stored in PropertyMapper, used to represents some property settings.
type PropertyMapperValue struct {
	// id represents the property order `id`.
	id int

	// revert represents if need `revert` in sort for destination.
	revert bool

	// arg represents some other arguments for property.
	arg interface{}

	// destinations represents the destination properties.
	destinations []string
}

// GetId returns the id in PropertyMapperValue.
func (p *PropertyMapperValue) GetId() int {
	return p.id
}

// GetRevert returns the revert in PropertyMapperValue.
func (p *PropertyMapperValue) GetRevert() bool {
	return p.revert
}

// GetArg returns the arg in PropertyMapperValue.
func (p *PropertyMapperValue) GetArg() interface{} {
	return p.arg
}

// GetDestinations returns the destinations in PropertyMapperValue.
func (p *PropertyMapperValue) GetDestinations() []string {
	return p.destinations
}

Return err when Duplicate

// CreateErr checks gorm.DB's create result.
func CreateErr(rdb *gorm.DB) (xstatus.DbStatus, error) {
	if IsMySQL(rdb) && IsMySQLDuplicateEntryError(rdb.Error) {
		return xstatus.DbExisted, nil // <<< rdb.Error
	} else if rdb.Error != nil || rdb.RowsAffected == 0 {
		return xstatus.DbFailed, rdb.Error
	}

	return xstatus.DbSuccess, nil
}

go-redis logger

Change gomodule/redigo to go-redis/redis, and use hook to add logger.

Notice that the value field is a private field in xxxCmd struct, need to use reflect to get it.

image

type hook struct{}

func (h hook) BeforeProcess(ctx context.Context, _ redis.Cmder) (context.Context, error) {
	return ctx, nil
}

func (h hook) AfterProcess(_ context.Context, cmd redis.Cmder) error {
	log.Println("=====================================")
	log.Println(cmd.String())
	log.Println(cmd.Name(), cmd.Args(), cmd.Err())
	log.Println("=====================================")
	return nil
}

func (h hook) BeforeProcessPipeline(ctx context.Context, _ []redis.Cmder) (context.Context, error) {
	return ctx, nil
}

func (h hook) AfterProcessPipeline(context.Context, []redis.Cmder) error {
	return nil
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.