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.

Database preparation in data designer

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.

Auth: get current user

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

Endpoint setup

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.

Server request get current user

When creating a record, it will save the data about the user who created it.

Was this article helpful?

AppMaster.io 101 Crash Course

10 modules
2 weeks

Not sure where to start? Get going with our crash course for beginners and explore AppMaster from A to Z.

Start Course
Development it’s so easy with AppMaster!

Need More Help?

Solve any issue with the help of our experts. Save time and focus on building your applications.

headphones

Contact Support

Tell us about your problem, and we’ll find you a solution.

message

Community Chat

Discuss questions with other users in our chat.

Join Community