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
Post a Comment