我是Sequelize初学者.我想oAuth通过Twitter或Facebook进行身份验证,并希望将用户信息保存在数据库中.但是,如果在多个站点上进行oAuth身份验证,则存在一个问题,即在数据库中注册的用户ID等信息将与其他站点重复.为了避免这种情况,我想只在数据库中尚不存在指定的用户标识时才进行更新数据库的过程.我知道我们可以使用sequelize的findOrCreate来进行这样的处理,但我不知道如何使用findOrCreate.我知道如何使用upsert,我想做findOrCreate,如下面的upsert描述.但是,我们想要执行条件分支,如if(userid!="○○○"&& username!="○○○").
User.upsert
({
userid: profile.id,
username: profile.username,
accountid: c+1
}).then
(() => {
done(null, profile);
});
Run Code Online (Sandbox Code Playgroud)
我在做什么?