I am creating a poll(like of hashnode) to help students suggest what should be done in classes . But the problem I am facing now is how to make a model that accept many and different option on the poll. I am used to yes/no option. So I would like to know how to make those different option on the poll.
Make option models:-
{ _id: ''option 1', option: "option name", vote: 100
}
{ _id: ''option 2', option: "option name2", vote: 100 }
Make model for students: -
{ _id: 'student model object_id', name: "abc", options: [ { _id: 'option 1', name: 'option name', vote: 'yes/ no' // to ensure student check this option or not }, { _id: 'option 2', name: 'option name2', vote: 'yes/ no' // to ensure student check this option or not } ] }
Now by this you can also manage options easily and differ options student to student.
Lars
German developer, who likes to play with everything that comes in his way
You could do something like:
{ "_id": "mongoid", .... some fields "options": [{ "name": "Option 1", "vote": 1 }, { "name": "Option 2", "vote": 100 }] }The option field contains an array of objects. Each object has two fields. The option name and the number of votes on this option.