Can't access my collections from the client

Hi guys! Ok so I have these two publications to get data from two collections that are defined as follows:

export const Conversation = new Mongo.Collection(‘conversation’);
export const Message = new Mongo.Collection(‘message’);

I also have to pubs in the server like so:

Meteor.publish(‘Message’, function(){
if (this.userId) {

return Message.find({‘conversation_id’:{$in:map}});


And I’m using a createContainer function to encapsulate data within the main component. I wrote my subs inside this function like so:

export default createContainer(() => {
const handleChat = Meteor.subscribe(‘Message’);
const handleChatReady = handleChat.ready();
return {

chatLog : handleChatReady ? Message.find().fetch() : false


It looks like the actual code is “well written”, since I’ve been accessing user data this way so far and the app’s been behaving great and reactive. However, when I added the pub/sub for the message/conversation collections, the data isn’t coming through.
Things I’ve checked(Not to many since I’m kinda noob):

-I noticed that if I type the subscription line into the browser, the data shows up
-I also noticed that, even though it says I should be able to type ‘Message.find()’ and get a cursos, I actually get Message is undefined, even after I manually subscribe from within the browser.
-I tried to change the pub to null so I can access it globally but still I can’t access using ‘Message.find()’ in the client.

Anything I’m missing here?

Kind of an obvious one, but have you tried running the same query in the mongo shell?

if you’re using a local db, you can start it with meteor mongo

Yes, I can do that, forgot to mention it in the post.
Also, I have meteortoys:allthings installed I’m showing the collections there. The Message collection currently empty because the subscription doesn’t go through, but I can totally se the Conversation collection there with the documents that I wanted it to show. I have its publication set up as null still just in case but I still can’t do a : “Conversation.find()” in the dev console in the browser

Another thing to check is that your collection is defined on both client and server

Ok here’s the part where I’m being completely honest and say that I kinda read the Folder Structure section in the Meteor docs and I thought I got that right but I have my doubts. I have both collections inside the following structure:


Inside the imports folder I have a subfolder called “api” and inside that, I have the actualy collection files Message.js and Coversation.js

I thought they were being run in both server and client only because meteortoys was always showing the collections and since thath’s something that’s being rendered in the browser I kinda got to that conclusion, but clearly not.

Also, I’m importing both files into the main.js that’s inside the server toplevel folder. Should I also import it in the main.js that bootstraps the client?

Your structure should be fine. For testing purposes, you can do this to access the collection from the console. I would recommend removing it afterwards.

// client
import { Message} from '/imports/api/message.js';

Template.<yourTemplate>.onCreated(function () {  
  window.Message= Message;
1 Like

OMG Thank you so much!!! I think I found out what was wrong, I was importing the whole file as in import ‘…/…/Message/Message’ but I didn’t use the { Message } thing. Everything seems to be working just fine now. I’m also kinda new to the import/export declarations so there’s that haha Again, thanks a lot!!!

This works, but aren’t Collections somehow accessible from the Meteor object in the browser console? Without having to use this work-around? If not, how does the client code access them!?

Did you find a solution @evolross I’m looking as well