
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

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

But all in all, thanks for your help. I learnt a thing or two

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

Alright.

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

Oh wow.

Alright thanks for the info.

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

Yes, this.

In the first approach you only store the chatId once somewhere

I'm just tryna avoid having to write more cloud functions 😅

but if each message contains chatId that can add up quite quickly

True this.

I'll do this anyways. Seems a lot cleaner

Yeah and I think permissions are somewhat easier to maintain I think

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: <fileId> type: image senderId: <userId of sender>
Recommended threads
- URGENT: Auth Data GONE and replaced by "...
This issue appeared suddenly and without warning yesterday. My auth page is replaced by the 404 error, and I don't have access to any users. When users try to l...
- when does request limit reset
it syas i need to update my plan but i dont want to do that yet, but i need to continue developing 🙂
- verification email
How do i send a verification email to a new user when they sign up without creating a session. I'm trying to use ssr. And I keep getting different answers where...
