You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use Red;
model CD { ... }
model Artist { ... }
model Track {
has Uint $.idis column{ :id };
has Uint $.cd-idis referencing{ CD.id };
hasStr$.titleis column;
has CD $.cdis relationship{ .cd-id };
has Artist $.artist=$!cd.artist;
::?CLASS.^add-unique-constraint: { .cd-id, .title };
}
lib/CD.pm6
use Red;
use Track;
model Artist { ... }
model CD {
hasUInt$.idis column{ :id };
hasUInt$!artist-idis referencing{ Artist.id };
hasStr$.titleis column;
hasUInt$.yearis column;
has Artist $.artistis relationship{ .artist-id };
has Track @.tracksis relationship{ .cd-id };
::?CLASS.^add-unique-constraint: { .artist-id, .title };
}
lib/Artist.pm6
use Red;
use CD;
model Artist {
hasUInt$.idis column{ :id };
hasStr:D$.nameis column{ :unique };
has CD @.cdsis relationship{ .artist-id };
has Track @.songs=@!cds.flatmap:*.tracks;
}