only store one snake with the same type and move Calculations into moves as the array<json> type
This commit is contained in:
+3
-13
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}""",
|
||||
|
||||
|
||||
Reference in New Issue
Block a user