I have a couple of subjects in mongodb and i want to have those subjects as choices when creating an examination.In the end,its desirable i have them saved in mongo like this
"examsubjects" : [
{
"mathematics" : "hCJes6DRwzgZzQvKK",
"anglais": "dhdjs77d8bcidjk"
}
],
where the subject choosen becomes the key.
This is my schema that i have in my collection
examsubjects: {
type: [Object]
},
"examsubjects.$.subject": {
type: String,
optional: true,
autoform: {
type:'select-checkbox-inline',
options: function(){
var cursor = Subject.find();
return cursor.map(function(doc) {
return {label: doc.subjectnames, value: doc._id};
});
}
}
},
When i try saving a subject i have picked,my code gives me this
How should i correct this?.