Rank 3: Container
Hmm. So how do you query this? Say you want to get a list of chats a user has
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 3: Container
Hmm. So how do you query this? Say you want to get a list of chats a user has
Haven't considered that. Yeah then you can save it
Rank 3: Container
In the last chat app I built with Realm, each chat object had a "participantsIDs" attribute. That way I could easily get a user's chats by querying the attribute using contains
Rank 3: Container
But all in all, thanks for your help. I learnt a thing or two
Rank 3: Container
I'd also like to know if there's a limit on the documents a collection could possibly hold
There is not really a limit
Rank 3: Container
Alright.
Rank 3: Container
Thank you
And even if there would be one it wake take a long time for you to reach it lmao
I literally inserted over 50m documents to a collection to test its effiency
It all still works fine
Rank 3: Container
Oh wow.
Rank 3: Container
Alright thanks for the info.
Rank 3: Container
I was wondering if to keep all the messages in a single collection or create a separate collection for each chat as you earlier mentioned
I would recommend separate collection for each chat
Otherwise you would have to include a chatId to the message model as well
Rank 3: Container
Yes, this.
In the first approach you only store the chatId once somewhere
Rank 3: Container
I'm just tryna avoid having to write more cloud functions 😅
but if each message contains chatId that can add up quite quickly
Rank 3: Container
True this.
Rank 3: Container
I'll do this anyways. Seems a lot cleaner
Yeah and I think permissions are somewhat easier to maintain I think
Rank 3: Container
Yeah. Thank you 🙏🏽
For image attachments you could create a function:
Everytime a user uploads an image to a bucket where the chatId act as bucketId, a function gets triggered an creates a document in the chat collection with
message:
type: image
senderId: