I am creating my own Riichi Mahjong App, and one thing got involved is call uma
, and postgres
is the only database that allow store that field as list of integer, which makes my schema looks like following:
...
model GameRule {
id Int @id @default(autoincrement())
gameType GameType @map("game_type")
name String @map("game_rule_name") @db.VarChar(255)
startingScore Int @map("starting_score")
notenPenalty Int @map("noten_penalty")
honbaSize Int @map("honba_size")
tiebreaker Tiebreaker
uma0Over Int[] @map("uma_0_over")
uma1Over Int[] @map("uma_1_over")
uma2Over Int[] @map("uma_2_over")
uma3Over Int[] @map("uma_3_over")
oka Int
chomboPenalty Int @map("chombo_penalty")
multiRonEnable Boolean @map("is_multi_ron_enable")
kiriageManganEnable Boolean @map("is_kiriage_mangan_enable")
multiYakumanEnable Boolean @map("is_multi_yakuman_enable")
stackYakumanEnable Boolean @map("is_stack_yakuman_enable")
riichiStickResolution RiichiStickResolution @map("riichi_stick_resolution")
createdAt DateTime? @default(now()) @map("create_time") @db.Timestamp(0)
updatedAt DateTime? @default(now()) @updatedAt @map("update_time") @db.Timestamp(0)
Game Game[]
@@map("game_rule")
}
...
I need to set all 4 uma
fields because based on the rule it actually different values, for example
I just try to test via graphql
using following:
mutation CreateGameRule($gameRuleInput:CreateGameRuleInput!){
createGameRule(input: $gameRuleInput){
id
name
gameType
startingScore
notenPenalty
honbaSize
uma0Over
oka
riichiStickResolution
tiebreaker
chomboPenalty
kiriageManganEnable
multiRonEnable
multiYakumanEnable
stackYakumanEnable
}
}
and with the variable input:
{
"gameRuleInput":{
"name":"Saikouisenn Rule",
"gameType":"YONMA",
"startingScore":30000,
"notenPenalty":3000,
"honbaSize":300,
"uma0Over":[
30,
10,
-10,
30
],
"uma1Over":[
0,
0,
0,
0
],
"uma2Over":[
0,
0,
0,
0
],
"uma3Over":[
0,
0,
0,
0
],
"oka":0,
"chomboPenalty":30,
"riichiStickResolution":"LOST_FOREVER",
"tiebreaker":"DIVIDE_EQUALLY",
"kiriageManganEnable":true,
"multiRonEnable":false,
"multiYakumanEnable":false,
"stackYakumanEnable":true
}
}
That is totally fine, so the only problem left will be the page.
After I run the yarn rw scaffold gameRule
, everything looks OK except that 4 uma
fields cause the problems… by default I only can enter a single number in there instead of array… how do I change this?