dimanche 19 avril 2015

How can I query MongoDB in a blocking way ? (not sure if this is the right way though)

Let me introduce my problem : I'm currently developing a web app using Node.js, Express and MongoDB (mongoose driver), and I would like, when the user requests /save, to generate an unique ID (made of random letters and digits) in order to redirect the request to /save/id.


Therefore I want my /save route to query MongoDB for a list of existing IDs, and generate a random ID which is not present in the list.


Any idea on how to do that ?


Aucun commentaire:

Enregistrer un commentaire