0

The driver for accessing my mongoDB database is mongoose, but this question is for all people, regardless of the programming language used. I created a user's schema, where I keep the username, password, email ... and a schema of the profile. It is better to connect (via _id) the profile to the user or the user to the profile

4

1 回答 1

1

这取决于您的用例。

如果您希望根据个人资料的内容找到用户,那么您需要一个Profile.user_id.

另一方面,如果您希望找到特定用户的个人资料,那么User.profile_id将是必需的。

如果您的用例需要这两个操作,则添加两个字段。

于 2018-08-19T16:54:33.200 回答