Help setting Foreign Key and Relationship using MongoDB

I want user to update their profile with additional information.

I just want to map the user to the specified collection.

Is there a way in MGO (or any other driver) to set relationship/foreign key for the table ?

thank you !

Sample existing application:

user name

I want to add Address, Contact Number, Age, ■■■, DOB details to the current user.

How can I achieve this using MGO or any other driver that could help achieve this ?

Have achieved the same using Ruby on Rails with Mongo as a DB but could not get this done using Go Language.

Kindly suggest , thank you :slight_smile:

MongoDB being NoSQL is a little different than the SQL method in how you can accomplish this:

Couple of choices there, references or embedding. But if you want to know more about references in mongo using mgo you’ll need the DBRef type:

Here are the mongo docs pages on the subject of references:

1 Like

thank you so much @CurtGreen :slight_smile:

Now I am slightly clear about setting the reference. Will try those :slight_smile:

Thanks again !

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.