I'm starting to start. I would like to authenticate using Twitter or Facebook and save the user information in the database. But if oAuth authentication is performed on several sites, there is a problem that information, such as the user ID registered in the database, will be duplicated with another site. To avoid this, I would like to make the database update process only when the specified user ID does not already exist in the database. I knew that we could use exelize findOrCreate for such processing, but I do not know how to use findOrCreate. I know how to use upsert, and I would like to find findOrCreate, as the description of upsert is below. However, we want to do conditional branching, for example if (userid! = "○○○" & username! = "○○○").
User.upsert
({
userid: profile.id,
username: profile.username,
accountid: c+1
}).then
(() => {
done(null, profile);
});
What should I do?
source
share