Expected relation or permission document
# spicedb
a
Expected relation or permission document:follower_content#reader@user:daniel to exist(document:follower_content#reader@user:daniel)
j
try using a check watch and seeing what it shows as a trace
j
so that works; try with user:daniel?
a
In subject? It doesn't appear as subject
Copy code
definition user {
    relation follower: user
}

definition document {
    relation reader: user | user#follower
    relation owner: user
    
    permission view = reader + owner
}
Copy code
document:follower_content#owner@user:adrian
user:daniel#follower@user:adrian
document:follower_content#reader@user:adrian#follower
j
user:daniel#follower@user:adrian
is backwards
it says that
adrian
is `daniel`'s follower
a
I'm having a hard time understanding the proper order atm
I can't tell which one is apropriate
j
resource@subject
a
Copy code
document:follower_content#owner@user:adrian
user:adrian#follower@user:daniel
document:follower_content#reader@user:adrian#follower
Like this right?
The problem becomes when you introduce follower and so on, I'm dyslexic and always struggle with those kind of logic lol
j
that should work
and yeah, it is confusing at times
a
Yeah it does
🙂
Thank you
It's very to me
j
might be helpful to switch to "grid" view
a
But it's ok
j
it says which is which
a
I will continue
Is there any more advanced examples somewhere in which user relationships are introduced?
Because the templates I see don't have user relationships usually anywhere
They don't have anything inside user even
One thing it's still not clear to me, should I define both that daniel is following Adrian and that Adrian is being followed by Daniel?
j
not offhand, but the way you did it is correct
> One thing it's still not clear to me, should I define both that daniel is following Adrian and that Adrian is being followed by Daniel? I wouldn't recommend doing so, it'll result in a resolution loop
a
Alright
j
unless you feel they need to follow each other
just make sure to not link their followers to each other
that will cause the loop
a
One last question I think, How would you define a friendship? Creating a definition?
Copy code
definition friendship {
????
}
j
do you want it to be bidirectional?
if so, yes
a
Yeah
But what do I put there?
Whatever, I guess, my problem now is more a naming thing I guess lol
Copy code
definition friendship {
relation user_a: user
relation user_b: user
}
This would work I think, will try
j
yeah
or just
relation user: user
you can have multiple users on the same relation
a
Not sure I'm following you there
j
Copy code
definition friendship {
  relation user: user
}
Copy code
friendship:somefriendship#user@user:adrian
friendship:somefriendship#user@user:joey
a
I see, but that seems unsafe, as one relationship can be left hanging, or even have 3 users in a friendship
I guess there is no safe way to do it right?
j
it could, but you'd make sure of that from your code
a
Yeah, it relies on application logic this is what I mean, there's no way to build a schema such that it wouldn't accept a relationship without more or less than 2 users
j
correct
its been requested to have validation rules on relations
but that has performance impacts
so we haven't done so yet
a
Yeah, makes sense, but yes, this seems like a must-have eventually
j
feel free to file an issue for it
I believe we have one already, but I cannot find it offhand
a
Will check when I'm more confortable with this so I cann communicate better
a
turns out I was already subbed to that, but wasn't aware that they meant that, seems very convoluted wording, but perhaps it's just my ignorance 🙂
j
well, its an example of a condition
you likely would want others
like the number of relationships on a relation