Mongoose best practices for document creation with unknown number of items in a field
<p>I've looked around left and right, I wrote some demo code, wrote some tests to implement a school management system. </p>

<p>What I want to know from people more used to mongoose development is how would be the best practice to create this schema in a way that made it possible to add as many address, and contact fees as I want from this single document. </p>

<p>I made my own solution, but I don't know if it is the most elegant and feasible way, I want an opinion from seasoned people.</p>

<p>Should I create separate models for address, email and phone numbers?</p>

<p>I created this schema. It still has some pseudo-code, but for giving the general idea is fine.</p>

<pre><code>var student = {
    name: String, 
    surname: String, 
    currentClass: {
        type: mongoose.Schema.Types.ObjectId, 
        ref: "Classes"
    }, 
    birthday: {
        year: Number,
        month: Number,
        day: Number
    },
    address: [{
        name: String, 
        zip: Number,
        address: String, 
        city: String, 
        state: String, 
        complement: String
    }]
    accountable: {
        name: String, 
        surname: String, 
        email: [{
            type: String, 
            required: true, 
            lowercase: true
        }], 
    phone: [String, String]
}
</code></pre>

<p>My sollution was, by using html, creating a new "email" or "address" fields as the user requested by clickinking in the propper button. This generated a new input field with a name that followed a pattern like:
email1, email2, email3, email4</p>

<p>And so, when the user sent the data, if we were creating a new student I would first create the array with the data and send it to mongoose.</p>

<p>In case of updating, I would get the already created emails and add it to the new array with the <code>newEmails.concat(old_emails)</code></p>