Meteor pub/sub since meteor 1.10.1

Hi guys,

i really need your helps with meteor pub/sub.
i have not faced this kind of Bugs for so long :frowning: . I know it is suppose to be a basic concept. But i am kind of missing something here. Please check my code and help me out. Please!

Thank you so much.
Love.


My collections
`
import { Mongo } from 'meteor/mongo';

export const CarDetails = new Mongo.Collection('carDetails');
`

My Collection method
`
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { CarDetails } from './carDetails.js';

Meteor.methods({
  'saveCarDetails'(carType, carCapacity, carModels, carCapacityByWeight){
  	  // check(carType, String);
	    // check(carCapacity, String);
	    // check(carModels, String);
	    // check(carCapacityByWeight, String);

     return CarDetails.insert({
           carType:carType,
           carCapacity:carCapacity,
           carModels:carModels,
           carCapacityByWeight:carCapacityByWeight,
           date: new Date(),
           author: Meteor.userId() 
      });
     }
});
`

Publications
`
import { Meteor } from 'meteor/meteor';
import { CarDetails } from '../carDetails.js';

Meteor.publish('trans_car_details', function () {
  return CarDetails.find();
});
`
On the clients

import CarDetails from '/imports/api/cardetails/carDetails.js';

Tracker.autorun(function(){
    Meteor.subscribe('trans_car_details');
});


Template.dashboard.helpers({

 CarDetails() {
    return CarDetails.find();
  }
});



Can you explain what sort of issue are you facing with this code?

1 Like

@hassansardarlecodeur here it is :frowning:
Exception from sub trans_car_details' id MB6nR8AJTPhmjQrjD TypeError: Cannot read property 'find' of undefined

Make sure the directory path of your model is correct for Publications here:

import { CarDetails } from '../carDetails.js';
1 Like

@hassansardarlecodeur yes, it’s correctly set

Publications
`
import { Meteor } from 'meteor/meteor';
import { CarDetails } from '../carDetails.js';

Meteor.publish('trans_car_details', function () {
  return CarDetails.find();
});
`

Can I get the reproduction repo for this?

Do you have any clues to tell me about pub/sub handler?

Yes. Actually the code seems right, but until and unless I don’t practically check the reproduced issue, I wont be able to help. So If you can provide a reproduction code, I can check it for you.

In one file, you are expecting CarDetails as the default export. From the other, you do not. Post the contents of your carDetails.js here to be sure

1 Like

@rjdavid


import { Mongo } from 'meteor/mongo';

export const CarDetails = new Mongo.Collection('carDetails');

Make your imports consistent. One of them is wrong

import CarDetails

vs

import { CarDetails }

3 Likes

@rjdavid thank you so much. Consistent import! :heart: