How to save information about the user who creates the record in the database?
Let's take a task scheduling application as an example. The user can create a task in the app and assign it to himself.
Creating a data model
First, create a relationship between the task and user models. Choose the has_many relationship type since one user can have several tasks.
Setting up a business process
Go to the Business logic tab and create a new business process.
Use only the Auth: Get Current User block and create a variable of User type in the END block.
Endpoint setup
Let's set up the endpoint for the new BP. Go to the Endpoints tab and add a new one.
Set up:
1. Endpoint type – GET
2. URL – /currentuser/
3. Endpoint Groups – User
Now add the created BP to the creation of a new record. Check how to do it in this article.
Insert the created BP before the Make block and pass the user value from the Server request GET /currentuser/ to the Make block.
When creating a record, it will save the data about the user who created it.