{"action":"created","issue":{"url":"https://api.github.com/repos/colinskow/superlogin/issues/18","labels_url":"https://api.github.com/repos/colinskow/superlogin/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/colinskow/superlogin/issues/18/comments","events_url":"https://api.github.com/repos/colinskow/superlogin/issues/18/events","html_url":"https://github.com/colinskow/superlogin/issues/18","id":122413706,"number":18,"title":"Conditionally add multiple DBs to new users","user":{"login":"christianmccormick","id":10410547,"avatar_url":"https://avatars.githubusercontent.com/u/10410547?v=3","gravatar_id":"","url":"https://api.github.com/users/christianmccormick","html_url":"https://github.com/christianmccormick","followers_url":"https://api.github.com/users/christianmccormick/followers","following_url":"https://api.github.com/users/christianmccormick/following{/other_user}","gists_url":"https://api.github.com/users/christianmccormick/gists{/gist_id}","starred_url":"https://api.github.com/users/christianmccormick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christianmccormick/subscriptions","organizations_url":"https://api.github.com/users/christianmccormick/orgs","repos_url":"https://api.github.com/users/christianmccormick/repos","events_url":"https://api.github.com/users/christianmccormick/events{/privacy}","received_events_url":"https://api.github.com/users/christianmccormick/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-16T02:33:49Z","updated_at":"2015-12-16T17:46:29Z","closed_at":null,"body":"I want to add several user DBs when a particular type of user signs up. I can't do this with defaultDBs as I don't want create these DBs for every user account, only ones with a particular type. Here's my code:\r\n\r\n````\r\nvar dbs = [\r\n  'example',\r\n  'dbs',\r\n  'to',\r\n  'add'\r\n];\r\n\r\nsuperlogin.on('signup', function(userDoc, provider) {\r\n  if (userDoc.user_type === 'special') {\r\n    dbs.forEach(function(db) {\r\n      superlogin.addUserDB(userDoc._id, db).then(function(res) {\r\n        console.log('Success: ' + res);\r\n      }, function(err) {\r\n        console.log('Error: ' + err);\r\n      });\r\n    });\r\n  }\r\n});\r\n````\r\n\r\ndbs is an array of the DB names that I want to create for a user with the user_type \"special\". The first DB gets created but the others all throw \"Document update conflict\" errors. I'm assuming that I'm using addUserDB incorrectly, but am stumped as to how. Any help would be appreciated! I've tried other approaches as well but nothing seems to work."},"comment":{"url":"https://api.github.com/repos/colinskow/superlogin/issues/comments/165190638","html_url":"https://github.com/colinskow/superlogin/issues/18#issuecomment-165190638","issue_url":"https://api.github.com/repos/colinskow/superlogin/issues/18","id":165190638,"user":{"login":"colinskow","id":5303269,"avatar_url":"https://avatars.githubusercontent.com/u/5303269?v=3","gravatar_id":"","url":"https://api.github.com/users/colinskow","html_url":"https://github.com/colinskow","followers_url":"https://api.github.com/users/colinskow/followers","following_url":"https://api.github.com/users/colinskow/following{/other_user}","gists_url":"https://api.github.com/users/colinskow/gists{/gist_id}","starred_url":"https://api.github.com/users/colinskow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colinskow/subscriptions","organizations_url":"https://api.github.com/users/colinskow/orgs","repos_url":"https://api.github.com/users/colinskow/repos","events_url":"https://api.github.com/users/colinskow/events{/privacy}","received_events_url":"https://api.github.com/users/colinskow/received_events","type":"User","site_admin":false},"created_at":"2015-12-16T17:46:29Z","updated_at":"2015-12-16T17:46:29Z","body":"You need to make sure `addUserDB` is finished before calling it again. \r\n\r\n```js\r\nsuperlogin.on('signup', function(userDoc, provider) {\r\n  var promises = Promise.resolve();\r\n  if (userDoc.user_type === 'special') {\r\n    dbs.forEach(function(db) {\r\n      promises.then(function() {\r\n        return superlogin.addUserDB(userDoc._id, db)\r\n      });\r\n    });\r\n  }\r\n});\r\n```"}}