I have meteor collection combined but have issue mentioned below

down vote
i am new to meteor have two collections of mongo user and patient i have concat them in console this code is displaying data but not in tempalte of html and in console i am showing data in objects but unable to show it on my html template see that images and kindly help meenter image description here enter code here

Template.showpatient.helpers({ ‘patientName’: function () {

        var tmpCollection = Patients.find()`
        tmpCollection.forEach(function (myDoc) {

            var a = Patients.find({"UserID": myDoc.UserID}).fetch().concat(user.find({"UserID": myDoc.UserID}).fetch())
            return a;


and at template side i am showing this like this

{{#each patientName}}





as i show in image see below in this image data is reteriving in console but not returning on my html template kindly help me about it

I may have misunderstood what you’re trying to do, but it looks like you want something like this:

  'patientName': function() {
    return Patients.find();

in fact i have two collections patient and user. i want to get the combine record from both collections and in both collections i have a field UserId and i want the records where both collections UserID have same value, and you can also say that me want to join and get two collections data where userid of both collections have same value

as i have show below

Patient ={UserId:'abcd ',FirstName:‘mudassir’,LastName:‘mama’}

user={UserId:'abcd ',FirstName:‘mudassir’,LastName:‘mama’}

You should take a look at reywood:publish-composite.

This would give you an array of all patients and users merged on a one to one basis

var mergedPatientUser = Patient.find().map(function(patient){
var user = User.findOne(patient.id);
return _.extend(patient, user);

A sub set of patients filt errerr ed on some field

var query = {department: “outpatient”};
var filteredAndMergedPatientAndUser = Patient.find(query).map(function(patient){
var user = User.findOne(patient.id);
return _.extend(patient, user);

A single patient

var patient = Patient.findOne(anId)
var user = User.findOne(anId)

var merged = _.extend(patient, user);

Sorry, in phone and about to board a plane

something like this should helps

i am using your way but it is not displaying data on template garrilla

‘patientName’: function () {

        var mergedPatientUser = Patients.find().map(function (patient) {
            var users = user.find({"UserID": patient.UserID});
            var patient = Patients.find({"UserID": patient.UserID});

            var b = _.extend(patient, users)
            return b;


mean in html no data is coming
or kindly brief it more clrearly i am troubling infact in displaying it how to display it as i am getting this in console i am showing you in image as i upload an image and i am now able to get one to one record relationed data from both collections but return is not working not showing it in html template

I think this package might help you https://atmospherejs.com/dburles/collection-helpers

this pakage have examples i try to follow them but not working as it is helping me in simple query and not in joining two collections when i use foreach it is not returning me result just findone is returning me results

‘patientName’: function () {
var merged = Patients.find().map(function(patient){
var users = user.findOne({“UserID”: patient.UserID}) // get the
return _.extend(patient, users);
return merged;

thanks this work for me thank you very much