I need to make a 1-to-1 relationship. like user-to-profile. both sides of the relationship will always exist, never any users without profile or profiles without users.and I need both to have a reference to the other side of the relationship.so when I create a user, I want to automatically create the profile doc in the profiles collection with the userId as the owner.my hang-up is, I also want to add the profileId in the user doc.I tried creating the user, then creating the profile and adding the user.id I got back from the user creation, then "findOneAndUpdate" on the user model to add the profiled once it was created.I'm not seeing the updates. whats a better way to approach this?
Submitted September 22, 2020 at 04:09AM by mdashcodes
No comments:
Post a Comment