Closed tanner0101 closed 7 years ago
Ream
class User: Object {
let teams = LinkingObjects(fromType: Team.self, property: "users")
}
In core data you set up two to-many
relationships that point to each other then some Xcode magic makes this happen:
let usersTeams = aUser.valueForKeyPath("teams.team")
Laravel
class User extends Model
{
public function teams()
{
return $this->belongsToMany('App\Team', 'projects', 'user_id', 'team_id');
}
}
Rails
class User < ApplicationRecord
has_many :teams through, :projects
end
I'm all for choosing the "fast" option, as that's one of the main reasons I chose to use vapor.
@hhanesand that's what we ended up going with :)
Using Protocol.Type
Pros:
through:
if you want default)Cons:
Using Generics
This syntax would be awesome but
Pivot<>
can't be a default argument andself
cannot be used to resolve the generic requirement.Pros:
Cons:
Siblings<User, Team, Pivot<User, Team>>