We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
db.Use(sharding.Register(sharding.Config{ ShardingKey: "user_id", ShardingAlgorithm: func(value interface{}) (suffix string, err error) { if uid, ok := value.(int64); ok { return fmt.Sprintf("_%02d", uid%4), nil } return "", errors.New("invalid user_id") }, PrimaryKeyGenerate: func(tableIdx int64) interface{} { // use Built in keygen for generate a sequence primary key with table index return keygen.Next(tableIdx) } }, "orders").Register(sharding.Config{ ShardingKey: "user_id", ShardingAlgorithm: func(value interface{}) (suffix string, err error) { if uid, ok := value.(int64); ok { return fmt.Sprintf("_%02d", uid%4), nil } return "", errors.New("invalid user_id") }, PrimaryKeyGenerate: func(tableIdx int64) interface{} { return uuid.UUID() } // This case for show up give notifications, activities table use same sharding rule. }, Notification{}, Acitivity{}))
The text was updated successfully, but these errors were encountered:
Fixed by #4
Sorry, something went wrong.
jinzhu
hyperphoton
No branches or pull requests
The text was updated successfully, but these errors were encountered: