Schema of undefined error


#1

Good Day,

I wrote the following schema which I’m passing into a quick form but I get the following error: Cannot read property
schema of undefined

Person = new Mongo.Collection('person');

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

const 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"
	},
	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’m not too sure why this isn’t working, I also tried the following, because as I understand it, you don’t need to pass schema into quick form once you attach it to collection. It will determine what kind of data to populate based on collection schema. However this doesn’t solve the issue, I’m pulling my hair out, any advice please guys!

Person.attachSchema(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"
    },
    User: {
        type: String,
        label: "User"
    },
}));