Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

316
Views
How can I select records n-at-a-time for multiple users to edit?

I am using a Django backend with postgresql.

Let's say I have a database with a table called Employees with about 20,000 records.

I need to allow multiple users to edit and verify the Area Code field for every record in Employees.

I'd prefer to allow a user to view the records, say, 30 at a time (to reduce burnout).

How can I select 30 records at a time from Employees to send to the front end UI for editing, without letting multiple users edit the same records, or re-selecting a record that has already been verified?

I don't need comments on the content of the database (these are example table and field names).

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

One way to do this would be to add 2 more fields to your table, say for example assigned_to and verified. You can update assigned_to, which can be a foreign key to the verifying user, when you allow the user to view that Employee. This will create a record preventing the Employee from being chosen twice. assigned_to can also double as a record of who verified this Employee for future reference.

verified could be simply a Boolean field which keeps track if the Employee has already been verified and can be updated when the user confirms the verification

The actual selects can be done like this:

employees = Employee.objects.filter(assigned_to=None, verified=False)[:30]

Then

for emp in employees:
        emp.assigned_to = user
        emp.save()

Note: This can still potentially cause a race condition if 2 users make this request at exactly the same time. To avoid this, another possibility could be to partition the employee tables into groups for each user with no overlap. This would ensure that no 2 users would ever have the same employees

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!