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
- Local Serverless Function Testing: Are D...
I have followed the instructions to get the CLI working, and have been able to log-in, initialize my project, and created a simple Python function, which calls ...
- Update user email using OTP
Hi, I am trying to implement email update using OTP, there is not password associated with the account. One solution I found online is creating appwrite functio...
- Magic Link token automatically consumed
Hi, I'm using the Magic Link auth system with Appwrite Cloud and I'm running into huge issues getting users to log in successfully. About 9 times out of 10, th...