dimanche 29 mars 2015

Keeping data consistency with multiple clients using nodejs and mongodb

I am creating a nodejs web server that uses mongodb, and I've encountered several situations where the data could be end up in a inconsistent state when multiple requests are being processed concurrently. For example, when creating a user, it would first check that the username does not exists, then it will create the user. But there would be a problem if, after it checked that the username does not exist but before creating the user, another client creates a user with that username. How can I prevent this problem? Is this easier to solve using a different database?


Aucun commentaire:

Enregistrer un commentaire