[Vuejs]-Sequelize / Vue / Node โ€“ I'd like to use a query to filter data after it has been returned to my view

0๐Ÿ‘

โœ…

If you need the exact same query on unfiltered data:

countResponses(this.totalQuizResponses);

function countResponses(quizData) {
  let counter = 0;

  for (const quizResponseA of quizData) {
    for (const quizResponseB of quizData) {
      if (quizResponseA === quizResponseB) { continue; }

      const isSameAnswerKey = quizResponseA.answerKey === quicResponseB.answerKey;
      const isSameQuizId = quizResponseA.QuizId === quizResponseB.QuizId;
      const isSameUser = quizResponseA.UserId === quizResponseB.UserId;

      if (isSameAnswerKey && isSameQuizzId && isSameUser) {
        counter++;
      }
    }
  }

  return counter;
}

If you already filtered your data with the same query, this.totalQuizResponses.length is the same as a counter for all the data you have locally

Leave a comment