javascript - Sequential requests to mongodb -


i writing node.js , mongodb app. cut long story short, small social network users registering , on. problem before adding user should check whether user same name exists. how can using promises? below current version of user adding code.

... function adduser(login, password){     return mongo.connectasync()return mongoclient.connectasync(url)                 .then(db => {                     // here should test login existance                     // , after need pointer db                     // register new user                 })                 .catch(err => {                     console.log('error--db_provider--addlog');                     throw err;                 }); } ... 


Comments

Popular posts from this blog

How to get the arclen between two curve points in Maya? -

C++ Linked List -

git svn - Unignore directories in git-svn (adding directories to a sparse checkout) -