title: How to add an array to a javascript server side model in MEAN.JS
body: <p>I am using MEAN.JS and I have created a module for projects. I would like to add tasks to these projects and I would like to do it with a multi-dimensional array. I would like the array to include a task.description and a task.status which would both be strings. I think I understand the client-side part of my project and I know there are still other files. However, I believe this will make the question as simple as possible, as I am struggling to get my profile developed on this site. I will however include controller.js, so I can get this working and hopefully give credit for a correct answer. </p>
  
  <p>project.server.model.js
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>'use strict';
  
  /**
   * Module dependencies.
   */
  var mongoose = require('mongoose'),
    Schema = mongoose.Schema;
  
  /**
   * Project Schema
   */
  var ProjectSchema = new Schema({
    created: {
      type: Date,
      default: Date.now
    },
    title: {
      type: String,
      default: '',
      trim: true,
      required: 'Title cannot be blank'
    },
    description: {
      type: String,
      default: '',
      trim: true
    },
    /* MODEL for TASK ARRAY*/
    task: {
  
    },
    user: {
      type: Schema.ObjectId,
      ref: 'User'
    }
  });
  
  mongoose.model('Project', ProjectSchema);</code></pre>
  </div>
  </div>
  </p>
  
  <p>projects.server.controller.js
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>'use strict';
  
  /**
   * Module dependencies.
   */
  var path = require('path'),
    mongoose = require('mongoose'),
    Project = mongoose.model('Project'),
    errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller'));
  
  /**
   * Create a project
   */
  exports.create = function (req, res) {
    var project = new Project(req.body);
    project.user = req.user;
  
    project.save(function (err) {
      if (err) {
        return res.status(400).send({
          message: errorHandler.getErrorMessage(err)
        });
      } else {
        res.json(project);
      }
    });
  };
  
  /**
   * Show the current project
   */
  exports.read = function (req, res) {
    res.json(req.project);
  };
  
  /**
   * Update a project
   */
  exports.update = function (req, res) {
    var project = req.project;
  
    project.title = req.body.title;
    project.description = req.body.description;
  
    project.save(function (err) {
      if (err) {
        return res.status(400).send({
          message: errorHandler.getErrorMessage(err)
        });
      } else {
        res.json(project);
      }
    });
  };</code></pre>
  </div>
  </div>
  </p>
  
  <p>edit-project.client.view.html</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;section ng-controller="ProjectsController" ng-init="findOne()"&gt;
    &lt;div class="page-header"&gt;
      &lt;h1&gt;Edit Project&lt;/h1&gt;
    &lt;/div&gt;
    &lt;div class="col-md-12"&gt;
      &lt;form name="projectForm" class="form-horizontal" ng-submit="update(projectForm.$valid)" novalidate&gt;
        &lt;fieldset&gt;
          &lt;div class="form-group" show-errors&gt;
            &lt;label for="title"&gt;Title&lt;/label&gt;
            &lt;input name="title" type="text" ng-model="project.title" id="title" class="form-control" placeholder="Title" required&gt;
            &lt;div ng-messages="projectForm.title.$error" role="alert"&gt;
              &lt;p class="help-block error-text" ng-message="required"&gt;Project title is required.&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
            &lt;label for="description"&gt;Description&lt;/label&gt;
            &lt;textarea name="description" ng-model="project.description" id="description" class="form-control" cols="30" rows="4" placeholder="Description"&gt;&lt;/textarea&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
            Task Description
            &lt;textarea name="description" ng.model="project.task.description" class="form-control" cols="30" rows="3" placeholder="Description"&gt;&lt;/textarea&gt;
            &lt;div&gt;
              Task Status
              &lt;input name="status" ng.model="project.task.status" class="form-control" placeholder="Status"&gt;  
            &lt;/div&gt;  
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
            &lt;input type="submit" value="Update" class="btn btn-default"&gt;
          &lt;/div&gt;
          
          &lt;div ng-show="error" class="text-danger"&gt;
            &lt;strong ng-bind="error"&gt;&lt;/strong&gt;
          &lt;/div&gt;
        &lt;/fieldset&gt;
      &lt;/form&gt;
    &lt;/div&gt;
  &lt;/section&gt;</code></pre>
  </div>
  </div>
  </p>