-
Notifications
You must be signed in to change notification settings - Fork 92
matrix rules example
bingoohuang edited this page Dec 23, 2013
·
1 revision
# 取订单前两位,直接映射到对应的数据库。
rule(10) pre(.order.id, 2) map(db$)
# 取订单后两位,直接映射到对应的数据库。
rule(11) post(.order.id, 2) map(db$)
# 取订单中间两位,直接映射到对应的数据库。
rule(11) mid(.order.id, 3, 2) map(db$)
# 取模,映射到不同的库。
rule(2) mod(.order.id, 3) map(0:dba, 1:dbb, dbc)
# 分表,女的到person_f表,男的到person_m表。
rule(3) val(.person.sex) map(0:.person_f, .person_m)
# 分库分表,按性别区分,女的到a库,男的按id分到b、c三个库。
rule(4) val(.person.sex) map(0:dba.person_f, rule->5)
rule(5) mod(.person.id, 3) map(0:dbb.person_m, 1:dbc.person_m)
#按范围,映射数据库。
rule(6) range(.order.id, ~1000:a, 1000~2000:b, 2000~:c) map(db$)