After importing collection I still get undifined in template helper


#1

Good day,

So I’ve defined a schema which I’m trying to pass to my template helper functions but for some reason I am getting a Exception in template helper: TypeError: Cannot read property ‘schema’ of undefined error.

I can for the life of me not figure out why I am getting this error:
Person = new Mongo.Collection(‘person’);

Person.allow({
	insert: function(userID, doc){
		return !!userID;
	}
});

List = new SimpleSchema({
	list: {
		type: String
	},
    outcome: {
    	type: String
    	}
});

PersonSchema = new SimpleSchema({
	FirstName: {
		type: String,
		label: "First Name"
	},
	LastName: {
		type: String,
		label: "Last Name"	
	},
	IdentityNumber: {
		type: Number,
		label: "Identity Number"
	},
	Address: {
		type: String,
		label: "Address"
	},
	PhoneNumber: {
		type: Number,
		label: "Phone Number"
	},
	List: {
      type: [List]
	},
	inHistory: {
		type: Boolean,
		defaultValue: false,
		optional: true,
		autoform: {
			type: "hidden"
	   }
	},
	User: {
		type: String,
		label: "User",
		 autoValue: function(){
         return this.userId;
      },
      autoform: {
            type: "hidden", 
            label: false,
		 },
		
		},
	
	//createdAt: {
	//	type: Date,
	//	label: "Created At",
	//	autoValue: function(){
			
	//	}
	//	autoForm: {
	//		type: "hidden"
	//},
	
});

I initially thought it was because I didn’t import my collection into my template helper file but now that I have done so I still get the exact same issue. I’m literally pulling my hair out. Please guys, guide me.

My template helper file:

import { Meteor } from 'meteor/meteor';
import { Person } from '/collections/person.js';

var global_var = true;

Meteor.subscribe('person');

Template.Person.onCreated(function(){
	this.editMode = new ReactiveVar(false);
	// this.editMode = new ReactiveVar();
	// this.editMode.set(false);
});


Template.Person.helpers({
	updatePersonId: function() {
		return this._id;
	},
	editMode: function() {
		return Template.instance().editMode.get();
	}
});

Template.Person.events({
	'click .toggle-menu': function() {
		Meteor.call('toggleMenuItem', this._id, this.inMenu);
	},
	'click .fa-trash' : function() {
		Meteor.call('deletePerson', this._id);
	},
	'click .fa-pencil' : function(event, template) {
		template.editMode.set(!template.editMode.get());
	}
});

My schema: