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
- getaddrinfo EAI_AGAIN when using axios
I have this code to make a get request to an API ```javascript function fetchUserListPerPage(page) { return new Promise(async (resolve, reject) => { ...
- Database Collection Permissions
Hi, i would like to create a document in a collection, and i would like to set up a permission so just the user who created the document can read it. This has t...
- custom push notification channel
Hi, Is there is a way to set a custom push notification channel in appwrite?