4

我正在构建的应用程序允许用户使用他们的 Facebook 和 Linkedin 帐户登录,以便从这些网络中获取他们的朋友。他们的每个朋友都可以是该应用程序的用户。

我有几个问题要解决:

  1. 我应该如何构建我的数据库模式?
  2. 如何统一配置文件?

潜在的解决方案

关于结构:

我正在使用 mongo (但我愿意接受建议)。所以我虽然我会创建一个每个用户文档看起来像这样collection的位置:Users

User = { appId: <id>, connections: [userId] }

因此,每个用户都有:

  1. 一个唯一的应用程序生成的 id(为简单起见,可能是文档的 id)。
  2. 一组用户 ID。在我的应用程序中创建的他们朋友的个人资料的 ID。

关于统一配置文件:

我应该根据用户的电子邮件或姓名统一用户吗?或两者?

杂项

我虽然可以使用LoginRadius,但我只是为此而单独使用,然后他们突然决定终止该服务。换句话说,我不想依赖第三方工具,因为这是一个核心功能。

4

1 回答 1

1
var UserSchema = new Schema({
                 name: { type: String, default: '' },
                 email: { type: String, default: '' },
                 provider: { type: String, default: '' },
                 hashed_password: { type: String, default: '' },
                 salt: { type: String, default: '' },
                 authToken: { type: String, default: '' },
                 facebook: {},
                 linkedin: {}
     })

I'm using the Schema mentioned above for my users collection.

and when a new user wants to Sign up, using either the local strategy or social strategies

I just use the update mongoose function with the "upsert: true" option, to either update or

create an entry.

于 2013-08-08T13:32:14.613 回答