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

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -