How to create collection base on an attribute update in documents using node js function? Collection name should be the data from updated attribute.
You want to create a collection if a document is updated?
Yes
It's a one time setup related function. So two users can use that same collection.
Sorry I don't understand
There is an attribute in User databse called roomName in my project. When two users connect I want that roomName to be their own collection. Where all the chat documents are inside that collection.
In general, you can have a function execute on an event like document update. The document would be in the event function variable. What part are you stuck on exactly?
Do you really need a collection per room? Why not just a collection of chat messages?
It's a couple's app each couple have their seperate collection. 1-1 communication
Again, why? You can use a team and document level permissions to restrict access so only the 2 in the team can read those chat messages
If I keep all the chat messages in one collection for all the users? Won't that cause privacy concerns and longer to pull data from server with real-time and queries?
As long as you have the permissions on place, there's no concerns with privacy. Pulling data is negligible
Okay.
Up to you. It typically makes the most sense to have a collection per data type. If you have multiple collections with the same attribute, you should have a good reason to do so
Mixing together all the messages of all users in a single collection doesn't sound good.
On the function part, are there any examples of events based trigger on demo in Node.js GitHub? And how to get that attribute name in the payload?
You should just deploy a function to see how it works. The document that was updated would be in the APPWRITE_FUNCTION_EVENT_DATA variable. See https://appwrite.io/docs/functions#functionVariables
It's pretty normal
Okay
Recommended threads
- Appwrite console is too heavy
The Appwrite console is too heavy And all of my services broken Any support , please
- router_deployment_not_found
I updated my function a few times and now i am getting the error: router_deployment_not_found I even reverted back to my original code but i am still getting th...
- 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...