This question is related to the one asked by @seref in this topic, but the problem persists if the DID in question is not the controller of the document.
Consider a simple model linking two users together:
type UserLink =
@createModel(accountRelation: LIST)
@createIndex(fields: [{ path: "toUser" }]) # Not possible :(
{
fromUser: DID! @documentAccount
toUser: DID! @accountReference
}
Let’s say I want to query for all users that have linked to a particular user. Since DID’s aren’t model instances, afaik it is not possible to add a relational frield to them. Additionally, since we can’t create the index in the type above this type of filtering is not possible either:
Huh, it indeed seems possible. I’m not sure what I did wrong initially, but it does seem to work and I can’t reproduce the errors I got Thanks!
EDIT: quite sure I wanted to use the @documentAccount field like in the linked topic, but for filtering in a deeper query where that DID is not the main subject. From that discussion I take it’s not possible? My guess is that it’s because that @documentAccount entry is a view and not actually part of the model?
A related follow-up though: is there a way of using @relationFrom views directly on DID/CeramicAccount nodes somehow?
Example: I want query for a specific node by DID and see the incoming UserLink entries (where it is the toUser). The outgoing is already there in the form of the built-in userLinkList that is automatically attached directly on the CeramicAccount. I’ve been trying to make this happen, but it only allows me to put views on models.
Consider the case where you have some type of user profile, and the owner has created a UserLink to some other user. I can’t show the outgoing links on the profile, but I can get to them indirectly by jumping to the owner (@documentAccount) and there query userLinkList.
There is however no way of showing the incoming links on a CeramicAccount because it doesn’t allow @relationFrom, not being a model. However, there is also no way of showing the incoming UserLinks on a separate profile model because it’s the DID that is the target so a @relationFrom will not match since they do not point to the profile but the account.
What’s the suggested way of dealing with this? Since the DIDs are valid StreamID entries in the model, it’s confusing that they cannot be used in the same way.
DIDs are not StreamIDs, they are completely different identifiers. DIDs represent accounts while StreamIDs represent unique streams (documents in ComposeDB).