mongodbmeteorsimple-schema

Uncaught Error: After filtering out keys not in the schema, your modifier is now empty


everyone. I am working on an attendance system using meteor.js. So I have two collections subject , student. In this system, a form will be submitted with selected studentID and subjectCode for subject enrollment. However, I got this error when I submitted. Uncaught Error: After filtering out keys not in the schema, your modifier is now empty.

The subject schema is like this

const subjectSchema = new SimpleSchema({
subjectCode:{
type: String,
label: “Subject Code”,
index:true,
unique:true
},
subjectName:{
type: String,
label: “Subject Name”,
index:true,
unique:true
},
enrollment:{
type: Array,
optional: true
},
‘enrollment.$’:String,
});

For actions

Template.enroll.events({
  'submit form':function(e){
    e.preventDefault();
    var name = $(e.target).find('[name=studentID]').val();
    var subjectCode = $(e.target).find('[name=subjectCode]').val();

    subject.update(
      {subjectCode:subjectCode},
      {$push:{"enrollment.$":name}});
  }
});

If anyone could help me out here I would really appreciate it. Thanks a lot.


Solution

  • The solution is here Meteor Forum.

    Code should be like this:

    subject.update(
          {subjectCode:subjectCode},
          {$addToSet:{"enrollment":name}});
      }