Good morning ! I come to you because I encounter a problem.
For fun, I'm developing a chat application, with "groups" made up of several users.
You can send messages in these groups.
I use Appwrite's "Teams" feature to manage groups and Appwrite's "Databases" feature to manage group messages.
Now I want to implement a system to know the number of unread messages. But I don't know how to do it without a complementary system like RabbitMQ, Memphis with their ACK systems.
Do you have any ideas to suggest to me? Thank you so much !
You want to display on read message per user in a given group?
Yes ^^
In the future with the adding of aggregation functions like count and sum, it will just one step. As of now what you'll need to fetch the data even that you just want to count it.
The process should be something like this. In the client device you should create table that holds each chat last read message ID, then you can run listDocuments where you search all message in the group after that ID.
If it's realtime then you can increase the counter each time a new message was receive in that group.
p.s. You can also set the last read ID in another collection, but for most of the time the local will be sufficient.
I think not storing anything on the client side due to lack of persistence & cross-platform. On the other hand, as you specify, in another collection, I can store the last id of the message read, it's a good idea ^^ Thanks !
👍
In case of cross platform then yes client side won't be the right way
I'm curious to know how aggreatation can work, I don't really understand ^^ Could you give me a little detail if possible? :D
Using aggregation like count will be much more efficient when counting those message. so instead of running listDocuments and count the results, (and paginiate if needed) you'll be able to something like so
let counter = databases.count(
"[DATABASE_ID]"
"[COLLECTION_ID]",
[
Query.equal('group', 'group_id'),
Query.greaterThan("$id", lastReadID)
]
);
This would be much more faster
Oh okay I see! I understand better now, thank you :)
Recommended threads
- is `account.get()` safe to be used in th...
I want to user's `id` for authentication. However, a while ago I was told in this server not to use `account.get()` and instead add user preferences for that us...
- Appwrite console is too heavy
The Appwrite console is too heavy And all of my services broken Any support , please
- Usage of the new Client() and dealing wi...
Hey guys, just a quick one - we had some web traffic the other day and it ended up bombing out - To put in perspective of how the app works, we have a Nuxt Ap...