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.
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
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:
app
|__imports
|__client
|__server
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.
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!?