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
- Couldnt not do appwrite push tables
Not sure why i am not able to create my tables
- DeploymentStatus enum value `canceled` m...
Hey, Sorry if it has been reported already, I found an issue using the Dart SDK where the `canceled` enum value is missing from `DeploymentStatus`. This causes...
- Synchronous function execution timeout w...
I am calling server functions with xasync = true and I still get this error message. Synchronous function execution timed out. Use asynchronous execution inste...