Query behavior for same parameters
I'm noticing interesting behavior for a specific query in my app for different users.
The query fetches a list of
messages
for a given user by conversation ID. e.g. fetchMessagesByConvoId(convoId: number)
The messages
table is indexed by conversationId
.
Within the query, I use the auth
object to fetch the user that called the query and use userId
to filter messages by calling something like query(messages).indexby(convoId).filter(ownerUserId == userId)
.
Then I return this list to my webapp. However, in the case that two different users fetch messages by the same convoId
, only the last user to call the query is returned the list of messages (the other user's list of messages becomes empty).
While this is a rare edge case for our app, I'm trying to understand why this happens. Do I need to disambiguate the queries by providing a different additional parameter for each user?2 Replies
No that shouldn’t be necessary. The behavior should be independent whether another user is also fetching messages. It sounds like there’s some other logic that is different between the two users. For instance, only one of the users might match the ownerUserId for a conversation
Resolved! thanks for the clarification