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

198
Views
Concurrency model mongodb doctrine symfony

I’m working on platform - MarketPlace with reservation. There are professionals who create availabilities. Availability is create with periods for example 8:00am to 5:00pm. It is the period that is saved in mongodb. The customer select a period of 1 hour. (The calendar for customer is generated dynamically with period of 1Hour) for example: for 8:00am to 5:00pm period there are: 8:00-9:00am, 9:00am-10:00am etc…

so it is not possible that 2 customers reserve the same period at the same time.

When customer select a period and click in «book button “the reservation object is saved in session. The customer buy this reservation and after the reservation object is saved in Reservation collection.

How to do for "lock" the period select by the first customer and prevent the second customer who want to reserve the same period?

And how I can fix the timer for 10 minutes and if there no payment for the period “availability” , unlock that period in the calendar? How create a chronometer synchronized with server and redirect to homepage when timeout is expired? Must i create a temporary collection with reservation in progress? Or save the object reservation in my collection Reservation with status "in progress"?

I use symfony 3 and mongodb with doctrine.

Thank you.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

How to do for "lock" the period select by the first customer and prevent the second customer who want to reserve the same period?

An update to a single document in MongoDB is atomic, that's why you can set reservation flag something like:

db.time_reservation.update(
    {_id: "<period primary key>", reserved: false,}, {
        $set: {
            reserved: true,
            reservedAt: new Date()
        }
    });

And how I can fix the timer for 10 minutes and if there no payment for the period “availability” , unlock that period in the calendar?

You can use cron command that will execute something like

db.time_reservation.update({
    reservedAt: {
        $lt: new Date(ISODate().getTime() - 1000 * 60 * 10)
    }
}, {$set: {reserved: false}});

How create a chronometer synchronized with server and redirect to homepage when timeout is expired?

Many possible solutions:

  • You can check this at every reservation stage

  • You can get timestamp from backend and validate it(save it to cookies if this is does'nt SPA)

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!