{"size": 1356, "ext": "js", "max_stars_repo_path": "Sem4/NoSQL/marks.js", "max_stars_repo_name": "nsudhanva/mca-code", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Sem4/NoSQL/marks.js", "max_issues_repo_name": "nsudhanva/mca-code", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Sem4/NoSQL/marks.js", "max_forks_repo_name": "nsudhanva/mca-code", "max_forks_repo_forks_event_min_datetime": "2018-10-12T06:38:14.000Z", "max_forks_repo_forks_event_max_datetime": "2019-01-30T04:38:03.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 22.9830508475, "max_line_length": 100, "alphanum_fraction": 0.3997050147}
// Create a collection called as marks that consits of the fields id, isa, quiz, assignments and esa
// isa, esa individual, quiz and assingments are array

db.createCollection('marks');

db.marks.insert(
    [
        {
            isa: 100,
            esa: 95,
            quiz: [20, 10, 15, 20],
            assingments: [40, 30, 20, 10]
        },
        {
            isa: 75,
            esa: 99,
            quiz: [34, 14, 12, 26],
            assingments: [60, 40, 23, 13]
        },
        {
            isa: 67,
            esa: 56,
            quiz: [40, 89, 56, 12],
            assingments: [10, 20, 30, 40]
        },
        {
            isa: 90,
            esa: 99,
            quiz: [20, 10, 15, 20],
            assingments: [60, 80, 70, 50]
        }
    ]
)

// Quiz totals, assingment totals of each student

db.marks.aggregate(
    {
        $project: {
            _id: 1,
            quiz: 1,
            assignments: 1,
            esa: 1,
            isa: 1,
            quizTotal: {
                $sum: "$quiz"
            },
            assignmentsTotal: {
                $sum: "$assignments"
            },
            fullTotal: {
                $sum: ["$isa", "$esa", { $sum: "$assignments" }, { $sum: "$quiz"}]
            }
        }
    }
)

db.marks.updateMany({}, { $rename: { "assingments": "assignments" } })
