user_id use Snowflake id,such as 79535114761158382
md5(user_id)
get first one letter for schema name, then join wkread_users_, such as wkread_users_a
every database host has two schema, such as wkread_users_2,wkread_users_3in the db06 host
first two letters for table name, then join user_, such as tables user_30,user_31``user_32``user_33``user_34``user_35``user_36``user_37``user_38``user_39``user_3a``user_3b``user_3c``user_3d``user_3e``user_3f in the schema wkread_users_3
2023/02/13 20:13:11 /Users/zhengjb/go/src/gitlab.y5ops.com/jin/hertz_demo/biz/repository/user_repo.go:30 sharding key or id required, and use operator =
[0.141ms] [rows:0] [replica] SELECT * FROM `user` WHERE `user`.`id` = 79535114761158382 ORDER BY `user`.`id` LIMIT 1
The document you expected this should be explained
Your Question
sharding rules as follows
user_id use Snowflake id,such as
79535114761158382
md5(user_id)
get first one letter for schema name, then join
wkread_users_
, such aswkread_users_a
every database host has two schema, such as
wkread_users_2
,wkread_users_3
in thedb06
hostfirst two letters for table name, then join
user_
, such as tablesuser_30
,user_31``user_32``user_33``user_34``user_35``user_36``user_37``user_38``user_39``user_3a``user_3b``user_3c``user_3d``user_3e``user_3f
in the schemawkread_users_3
Sharding is as follows in my project
database conf
database dialector is mysql
query a user by uid code as follows
get an error when run
The document you expected this should be explained
Can not
db.Use
used whendb.Clauses
is used ?cannot use Clauses
Expected answer
get a user as expected. or how to do as described ?