From 171079d9079f5f2cff0199ed15c89992f79803d5 Mon Sep 17 00:00:00 2001 From: marvin Date: Wed, 19 Jan 2022 10:41:15 +0800 Subject: [PATCH] update README --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3a6b593..cc135d7 100644 --- a/README.md +++ b/README.md @@ -43,18 +43,18 @@ Config the sharding middleware, register the tables which you want to shard. See ```go middleware := sharding.Register(map[string]sharding.Resolver{ - "orders": { - ShardingColumn: "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) int64 { - return node.Generate() - }, - }, + "orders": { + ShardingColumn: "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) int64 { + return node.Generate() + }, + }, }) ```