heyo,
How would I go towards making a document in a collection the moment a user gets created? I get the events part in the console, but how would that look like in the code?
Do I check every user and see if they all have a document? Does the event users.*.create send specific data to the function before it starts? like what user has been created?
When you subscribe to users.*.create the whole user object is passed to your function as the payload.
export default async ({ req, res, log, error }) => {
const document = req.body as Models.User<{}>;
log(document);
// Your logic here
};
Here is an example function for you (TypeScript). These are the properties of the user: https://appwrite.io/docs/references/cloud/models/user
Thank you! That really helps :)
[Solved] How to properly create document on user creation
I am facing the same type of problem. I had my function working with older version of appwrite. But am having difficulty with new syntax.... am a beginner... The docs are complete but a bit complicated for me.
I am working with flutter / dart
When you say : with users.create event, the whole user object is passed as payload to the function... so I understand we have a way to recuperate all the info about the user... but how does the syntax work ?
Please create a new support thread.
ah.. I thought it was better here since it's the same thing
sorry
No worries :)
Recommended threads
- I can't UNPAUSE my project with the free...
I received an email notifying me that my project had been paused due to inactivity, and the email included a link to "Restore project." However, that button red...
- Error trying to deploy functions from CL...
✗ Error • on-auth-create (6a00b2ab000c9ce2949b) • Server Error ✗ Error: No functions were pushed. Prject ID: 69ffe0270033a4ac420a
- Intermittent Deploy and Execution Errors...
Project: project-fra-658e2f5f4ba30df91177 Function ID: 69bde006001c56757f49 **Several execution errors with:** Timed out waiting for runtime.\nError Code: 400...