Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda