[Solved] Cannot get past todo tutorial, collections

Hello,

I am trying to do https://www.meteor.com/tutorials/blaze/collections tutorial. But for some reason I am not able to reflect the data to my page.

The only difference is that on the tutorial, it is using a default package setup whereas I used the --full flag when I created the project.

I did what the tutorial said, create the collections file in imports/api and then import it in server/main.js

I have also added some entries to the tasks collection. For some reason, I am not able to get the data from the server to my template page. I have no errors whatsoever on the browser.

I am using constellation and it says I don’t have any values retrieved from tasks.

this is a bit frustrating since the intermediate video tutorials worked without having to import specifics but now I’m lost. not really sure what the issue is

Just to add, when I enable autopublish on constellation, my data suddenly appears.

imports/ui/pages/home/home.js >>>>>>>>>>>>>>>>>>>>>>

import { Template } from 'meteor/templating';
import { Tasks } from '/imports/api/tasks.js';
import './home.html';

Template.App_home.onRendered(function () {
  console.log(Tasks.find({}).count());
});

Template.App_home.helpers({
    tasks() {
        return Tasks.find({});
    },
});

imports/api/tasks.js >>>>>>>>>>>>>>>>>>>>>>

import { Mongo } from 'meteor/mongo';
import { Meteor } from 'meteor/mongo';

export const Tasks = new Mongo.Collection('tasks');

server/main.js >>>>>>>>>>>>>>>>>>>>>>

import '/imports/startup/server';
import '/imports/startup/both';
import '../imports/api/tasks.js';
1 Like

Not to put too fine a point on it - you’re not actually following the tutorial at all.

In this case, your issue is most likely down to using constellation, since the tutorial (as published) uses autopublish up to step 10, where it’s removed in favour of explicit publications.

1 Like

This indeed should work, but only for demo purposes. Normally (as you’ll learn further on in the tutorial) you have to publish the tasks using Meteor.publish. However, thanks to a Meteor package called autopublish, you don’t have to. Can you check if this package is listed in the following file?

.meteor/packages

If its not there, the reason is likely that using the --full flag will not give you autopublish and insecure. Which sounds logical, because these 2 packages should not be part of a production app. (These 2 only exist for learning purposes)

3 Likes

hey guys thanks for pointing out these small details that I honestly overlooked. upon checking, autopublish is not visible in my package list because I used the full flag on creation of the project.

I am now able to proceed with the tutorial upon redoing the tutorial using no flag on the creation of the project.

3 Likes