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?
Summary
There was a question about how to create a document in a collection when a user is created. The solution provided is to subscribe to the `users.*.create` event and use the whole user object as the payload in the function. The example function provided is in TypeScript and demonstrates how to access the properties of the user object. The user object properties can be found in the documentation.
WhiteWalker72
Rank 2: Process
Nov 20, 2023, 15:25
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
};
[Solved] How to properly create document on user creation
SylvainJack
Rank 1: Thread
Nov 22, 2023, 16:48
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.
SylvainJack
Rank 1: Thread
Nov 22, 2023, 16:49
I am working with flutter / dart
SylvainJack
Rank 1: Thread
Nov 22, 2023, 16:50
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 ?
fafa
Rank 4: Virtual Machine
Nov 22, 2023, 16:50
Please create a new support thread.
SylvainJack
Rank 1: Thread
Nov 22, 2023, 16:50
ah.. I thought it was better here since it's the same thing