-
Notifications
You must be signed in to change notification settings - Fork 4.4k
🚀 Feature: Realtime Query Listening #2490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Interesting idea, not sure about a possible implementation. Especially since our realtime server works with all services and resources of Appwrite - not just the Database. Something like this is already possible with the current solution - just not out of the box and completely optimized. I will keep this issue in the backlog for the future 🙏🏻 |
This is definitly an interesting feature. At this moment there are to few options to listen to changes on the DB. |
+1 adding filters to collection subscription would add a lot of flexiblity. |
Related discussion |
You can do that now but it's not straight forward.
It would be great if we had something like in Firebase by doing all this on the background either on the server side or client side through the Sdk. |
One of the solutions. I create collections by parameter name and write objects with the appropriate parameters to them. And I listen to collections with the parameters I need. If the parameter changes, delete the object and write it to another collection. I don't know how much I clearly put it. |
Yes, the 3rd step is the crucial one that doesn't have a general solution with the current implementation. I don't think this can be done on the client at all in a way that is scalable, especially not with limited resources on mobile devices.
This is very clever, but would quickly grow unmanageable for more complex apps. |
The best idea to convert all sdk methods to REST API Queries and use axiosInstance.interceptors from axios npm package. |
This feature for realtime update based on query is needed. Example I may have a collections called States then I may have attributes called city, zip code, etc. In my React application I may have filters where I only want to subscribe to changes only if a zip code matches in the database |
This is a very necessary feature for realtime use. Imagine a live-ticker scenario. Subscribing to the collection means you get all events from all games, while you may only be interested in 1% or less of them. Pushing out all events to all clients has a huge impact on performance. The wasted bandwidth on both the server and the clients is unacceptable, so the Realtime feature of appwrite cannot be used. Being able to apply queries to the subscription would eliminate this. |
@WasserEsser, that's not completely the case, each user will only receive updates from objects he has permission to view. With correct permission handling by your app, each user would receive only updates that he is granted to access, that may still be more than what you really need depending on the use case but IMO it's acceptable enough and realtime can indeed be used with proper permission management. |
@merabtenei You completely missed the point of my post. It's a live ticker. Anyone has and should have access to any game they want to see. Dynamically granting and revoking access based on which game you clicked on is not a solution, it's an awful dirty hack. If there is no way to do it properly, appwrite is not the solution for this use-case. |
Up |
@merabtenei I asked this question today in discord live event like that are you planning to add this feature in future. They suggest me to use permissions as well. I dont have any deep experience with permissions but i think while creating a document, im able to put permission which is related exactly current user. If it works as expected, then no need to have this feature/issue. Websocket is going to send you only related updates. |
Again, this is not a solution. Using permissions to scope events should be done for their exact purpose, blocking people from receiving events they have no right to access, while in my case, they have every right to access them, they just don't want them. This feature is very necessary. |
waiting for this feature |
1 similar comment
waiting for this feature |
Since realtime gives us a payload, but we would like to have something middleware or a filter method in Realtime subscribe that will have conditions something like for sample Query("consultType", "adasd"), then the server side will check it first if the payload contains this attribute then check if equal to this value. Since the realtime works with all service not only Database, but the thing is we have payload key from the Realtime response then we can use this. We can do this in client side, but it prefers that server side should handle this. |
waiting for this feature |
Very much needed feature! Permission management is not a solution here - just an ugly workaround. Imagine a social media app where users subscribe to a collection of public posts. Every post is accessible to all users, and permissions allow everyone to read any document. However, users only want to receive real-time updates for posts containing specific hashtags they care about (e.g., #Flutter, #Coding, #Games...). As the app and user base grow, client-side filtering becomes unmanageable due to excessive, unnecessary events, making it very poor for scalability. Firebase already supports this. Why can't Appwrite add it too? |
It would be more productive if we discussed possible implementations. I've recently been working with Prisma, which offers a service called Pulse. Pulse is very similar to this feature request, as it allows you to write a query and stream rows in the database that match it. Pulse is not open source, so I decided to create my own version of it. My version uses Postgres' WAL feature, Kafka, and Debezium. WebSocket clients connect and specify a query that they want to listen to. Whenever a database change occurs, my Kafka handler is ran, being given both the row and operation that is occurring ( For each condition in a query like equals: (columnValue, conditionValue) => {
return columnValue === conditionValue
},
startsWith: (columnValue, conditionValue) => {
return columnValue.startsWith(conditionValue)
},
contains: (columnValue, conditionValue) => {
return columnValue.includes(conditionValue)
},
greaterThan: (columnValue, conditionValue) => {
return columnValue > conditionValue
}, Handlers are given the column's value, and the query's condition value. The handlers return whether the column's value conforms to the condition specified by the query. If all handlers return true, then the WebSocket is notified of the row. This differs from Firestore, which notifies you of new query results rather than just rows that match those query results, but that behavior could be adjusted. This isn't a perfect solution, but I just wanted to offer one that's worked for my needs in another library. I'm curious if others have input on this. |
Real-Time Query Subscriptions (Filtered Realtime) in Appwrite Summary Real-World Example: SaaS with Multi-Tenant Data Imagine a multi-tenant SaaS platform where each “tenant” is an organization. A typical database structure might look like this: - Collection:
Since Appwrite currently doesn’t support query-based Realtime subscriptions, we only have these options: 1. Subscribe to the entire
2. Subscribe to each task individually (by ID)
Both approaches are problematic in a real-world SaaS environment. Why We Need Real-Time Query Subscriptions
Desired API / Feature Proposal A potential approach could look like:
In this scenario:
Why It’s Urgent for Many SaaS Apps When building a multi-tenant SaaS, real-time updates are a core user experience feature. For example, a team board or project management app that shows tasks in real time for each organization. Without query-based filtering, devs must either:
A proper, server-side Realtime query filter is essential for secure and efficient multi-tenant architectures. Shout-Out We appreciate the amazing work on Appwrite so far and hope you’ll consider adding Real-Time Query Subscriptions to the roadmap. It would be a game-changer for many production use cases. Thank you for reviewing this request! |
🔖 Feature description
Firebase allows you to actually listen to query results. If the results of your query would change if you ran it again, you are automatically given the latest results of your query in realtime.
https://firebase.google.com/docs/firestore/query-data/listen#listen_to_multiple_documents_in_a_collection
🎤 Pitch
This would allow realtime capabilities to be used with filters and offsets and such in a very simple manner.
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: