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
It is unclear how indirect relationships (using :model<ModelName> to define them) are implemented, just from the examples.
I had an issue whereby my Red setup did not know how to find a model, because it was not in a file by that name:
# Schema.pm6
model A {
has Int $.id is serial;
has @.rel is relationship({.a-id }, :model<B>);
}
model B {
has Int $.id is serial;
has Int $!b-id is referencing{ :model<B>, :column<id> };
}
The parameter :require<Schema> can be used to tell Red that it should load that module to find that relationship, but this can be cumbersome. A bigger example might be:
# lib/MyApp/Schema/A.pm6
model LongTableName {
has Int $.id is serial;
has @.rel is relationship({.a-id }, :model<RealLongTableName>, :require<MyApp::Schema::RealLongTableName>);
}
A possible solution (I don't know whether this is feasible since I am still experimenting with Perl 6) would be to remember a model once it is declared; Red already makes use of global state, so this doesn't seem like a terrible option if it can be done. That way, you would only need to know how to find a :model if it hasn't been seen before, and the way to use Red would be to make sure all your models have been loaded before you do anything else.
The text was updated successfully, but these errors were encountered:
It is unclear how indirect relationships (using
:model<ModelName>
to define them) are implemented, just from the examples.I had an issue whereby my Red setup did not know how to find a model, because it was not in a file by that name:
The parameter
:require<Schema>
can be used to tell Red that it should load that module to find that relationship, but this can be cumbersome. A bigger example might be:A possible solution (I don't know whether this is feasible since I am still experimenting with Perl 6) would be to remember a model once it is declared; Red already makes use of global state, so this doesn't seem like a terrible option if it can be done. That way, you would only need to know how to find a
:model
if it hasn't been seen before, and the way to use Red would be to make sure all your models have been loaded before you do anything else.The text was updated successfully, but these errors were encountered: