I am trying delete a specific index from the questions array. I have followed the examples in these two posts:
In mongoDb, how do you remove an array element by its index
How to delete n-th element of array in mongodb
var quiz = {
quizName: "",
createdBy: "",
theme: "",
isPrivate: "",
expiringDate: "",
createdOn: "",
questions:[
{question: "",
index: "",
answers: [
answer: "",
radioCorrect: "",
index: ""
]},{
question: "",
index: "",
answers: [
answer: "",
radioCorrect: "",
index: ""
]}
]
This is giving me a not specified error. I have tried similar variations of this.
'deleteQuiz': function(quizId, index1){
Quizes.update({_id: quizId},{ $unset : {questions.index1: 1}})
Quizes.update({_id: quizId},{ "$pull" : {"questions": null}}) }