only store one snake with the same type and move Calculations into moves as the array<json> type

This commit is contained in:
2024-05-08 15:38:14 +02:00
parent bb92715de1
commit aba457423e
2 changed files with 5 additions and 19 deletions
+3 -13
View File
@@ -34,10 +34,8 @@ module default {
readonly := true;
on source delete delete target;
}
single snake: Snake {
required single snake: Snake {
readonly := true;
on source delete delete target;
on target delete allow;
}
}
@@ -68,7 +66,7 @@ module default {
required type: str {
readonly := true;
}
#constraint exclusive on .type;
constraint exclusive on ( .type );
}
type Moves {
@@ -81,15 +79,7 @@ module default {
required game_board: json {
readonly := true;
}
single calculations: Calculations {
readonly := true;
on source delete delete target;
on target delete allow;
}
}
type Calculations {
required data: array<json> {
calculations: array<json> {
readonly := true;
}
}
+2 -6
View File
@@ -47,11 +47,7 @@ class EdgeDB:
turn := data.turn,
snake_move := data.`move`,
game_board := data.game_board,
calculations := (
insert Calculations {
data := data.calculations
}
)
calculations := data.calculations
}
),
type := (
@@ -70,7 +66,7 @@ class EdgeDB:
snake := (
insert Snake {
type := <str>$snake_type
}
} unless conflict on .type else Snake
)
}""",