Wednesday, 12 April 2017

how to count and display number of objectid from specific array

dataBase schema

var adminSchema = new mongoose.Schema({
    electionName : {type: String, unique: true},
    endDate      : {type: Date},
    candidates   : [{type: mongoose.Schema.Types.ObjectId, 
                    ref: "candidate"}] 

var candidateSchema = new mongoose.Schema({
    name : String,
    partyName: {type: String, unique: true},
    information: String,
    votes: [{type: mongoose.Schema.Types.ObjectId, 
                    ref: "vote"}]

var voteSchema = new mongoose.Schema({

    counter: Number

Here, I have referenced and pushed data/objectid from votes to candidates and from candidates to electionSchema , now I want to count the number of vote/objectid of all individual candidates from different elections.



via Abhijeet Baviskar

No comments:

Post a Comment