title: How to manipulate mongoose query result in exec callback
body: <p>I am a newer in meanjs. Now I am stuck in how to manipulate the data queried from mongodb using mongoose. Here is my case:</p>
  
  <p>Model schema is this:</p>
  
  <pre><code>var AdminUserSchema = new Schema({
  firstName: {
      type: String,
      trim: true,
      default: '',
      validate: [validateLocalStrategyProperty, 'Please fill in your first name']
  },
  lastName: {
      type: String,
      trim: true,
      default: '',
      validate: [validateLocalStrategyProperty, 'Please fill in your last name']
  },
  displayName: {
      type: String,
      trim: true
  },
  email: {
      type: String,
      trim: true,
      default: '',
      validate: [validateLocalStrategyProperty, 'Please fill in your email'],
      match: [/.+\@.+\..+/, 'Please fill a valid email address']
  },
  username: {
      type: String,
      unique: 'Username already exists',
      required: 'Please fill in a username',
      trim: true
  },
  password: {
      type: String,
      default: '',
      validate: [validateLocalStrategyPassword, 'Password should be longer']
  },
  salt: {
      type: String
  },
  provider: {
      type: String,
      required: 'Provider is required'
  },
  providerData: {},
  additionalProvidersData: {},
  roles: {
      type: [{
          type: String,
          enum: ['user', 'admin']
      }],
      default: ['admin']
  },
  updated: {
      type: Date
  },
  created: {
      type: Date,
      default: Date.now
  },
  /* For reset password */
  resetPasswordToken: {
      type: String
  },
  resetPasswordExpires: {
      type: Date
  },
  enabled: {
      type: Boolean,
      default: true
  }
  </code></pre>
  
  <p>});</p>
  
  <p>When I try to get data and manipulate with following code:</p>
  
  <pre><code>var AdminUser = mongoose.model('AdminUser');
  AdminUser.find().exec(function(err, users) {
      if(err) {
          return res.status(400).send({
              message: errorHandler.getErrorMessage(err)
          });
      } else {
  
              users[1].password = undefined;
              users[1].salt = undefined;
              var created = moment(users[1].created).format('YYYY-MM-DD');
              users[1].created = created;
  
              console.log(created);
              console.log(users[1].created);
              console.log(users[1]);
      }
  });
  </code></pre>
  
  <p>The result shows as follow, it just doesn't work.</p>
  
  <p>2015-04-07</p>
  
  <p>Tue Apr 07 2015 12:00:00 GMT+1200 (NZST)</p>
  
  <pre><code>{
      _id: 55233e0c488bd50b1eafe558,
      salt: undefined,
      displayName: 'testtest',
      provider: 'local',
      username: 'test',
      __v: 0,
      enabled: true,
      created: TueApr07201512: 00: 00GMT+1200(NZST),
      roles: [
      'admin'
      ],
      password: undefined,
      email: 'test@test.com',
      lastName: 'test',
      firstName: 'test'
  }
  </code></pre>
  
  <p>I have tried to manipulate with like this:
  <code>users[1]['created'] = created;</code></p>
  
  <p>or using set function:
  <code>users[1].set('created', created);</code></p>
  
  <p>both failed. Please give a hand.</p>
  
  <p>Any help would be appreciated.</p>