@tdtank
Nothing in my code should cause there to be more queries than before. The piece you are using simply uses a different “join” table (no table, in this case).
DataMapper has always run a query every time you call ->get(). Since each type of user is related differently, it is going to be a different join.
There really isn’t a way in SQL to query multiple objects in different relationships into the same result set, especially without losing the “meaning” of the relationship. So, if the same user is related as “editor” and “creator”, that user will be queried twice.
I can look into seeing if there is a practical way of looking through the relationships and seeing if the same object is already loaded, but that probably won’t be terribly efficient, especially since these primary key queries.
@DominixZ
As it says in the manual, you can delete multiple relationships using one call. However, that is completely unnecessary in your case, because calling $bookmark->delete() automatically deletes all relationships (also mentioned above, in red). You don’t even have to ->get() the related items:
$bookmark = ...
// delete bookmark and all relationships (but not the related items themselves)
$bookmark->delete();