How to Store Employee Attendance Data from API into Bubble Database without Duplicates (Starter plan)

Hello, Bubble Community!

I’m working with the API Connector to fetch attendance data for multiple employees, and I’m on the Starter plan. The API returns the following JSON format:

{
“result”: [
{
“attendanceDetails”: {
“2024-08-26”: {
“ShiftStartTime”: “12:00 AM”,
“Status”: “Janmashtami(Holiday)”,
“TotalHours”: “00:00”
},
“2024-08-27”: {
“ShiftStartTime”: “12:00 AM”,
“Status”: “Present”,
“TotalHours”: “08:56”
}
},
“employeeDetails”: {
“mail id”: “hidden”,
“first name”: “hidden”,
“last name”: “hidden”
}
},
{
“attendanceDetails”: {
“2024-08-26”: {
“ShiftStartTime”: “12:00 AM”,
“Status”: “Janmashtami(Holiday)”,
“TotalHours”: “00:00”
},
“2024-08-27”: {
“ShiftStartTime”: “12:00 AM”,
“Status”: “Present”,
“TotalHours”: “09:25”
}
},
“employeeDetails”: {
“mail id”: “hidden”,
“first name”: “hidden”,
“last name”: “hidden”
}
}
]
}

I would like to store this data into my Bubble database, in a table with the following fields:

  • Date
  • Employee’s email
  • Total Hours
  • Status

The idea is to:

  1. Store the data for each date and employee (coming from the API’s attendanceDetails and employeeDetails).
  2. Prevent duplicate entries: If data for a specific date and employee already exists in the database, skip adding that entry.

I’ve already connected the API and can pull the data, but I’m struggling with the logic to iterate over each employee and their dates, and then check for existing records before saving new ones.

Can someone guide me on how to set up the workflow to achieve this?

Thank you in advance for your help!

image


@tunacardak

can anyone help me?

I’m confused about how to store each employee’s details along with all the corresponding dates.

@bogdananpi

This is difficult in Bubble as it is not very performant, but can still be done.

Check all the threads that exist on the Forum about this specific type of issue in regards to taking API JSON data and storing them in the database. Lots of threads on the forum with the same answers provided, most of which involve recursive backend workflows.

If your API data is different from the DB datastructure, you could simplify things and just make the DB datastructure mirror that of the API data, so instead of using a range, use two fields, one for start and one for end…alternatively, just take the API start and API end and use those for creating your range in the DB.

@boston85719

This topic was automatically closed after 70 days. New replies are no longer allowed.