[Vuejs]-Linking two collections from mongoDB with vue.js

1👍

In case you are using MONGOOSE, you can do it with ref

var mongoose = require('mongoose')
  , Schema = mongoose.Schema

var businessSchema = Schema({
    name : String,
});

var userSchema = Schema({
    businessDetails: { type: Schema.Types.ObjectId, ref: 'Business' },
    gender: {type: String, enum: ["Male", "Female"]},
    city: String
});

var User = mongoose.model('User', eventSchema);
var Business = mongoose.model('Business', personSchema);

function getUserDetails (callback) {
   User.find().populate({'businessDetails'}).callback()
} 

Here you will get data like

[
   {
      businessDetails: {
                            name: "Harshal",
                            gender: "Male",
                            city: "Pune"
                        }
   }
]

Now you can display on UI as you want.

Leave a comment