"use strict"; 

var mongoose            = require('mongoose'),
    Schema              = mongoose.Schema;

var PostSchema = module.exports = new Schema({
  _id: {
    type: String,
    default: function() {
      return (new mongoose.Types.ObjectId()).toHexString();
    }
  },

  label: { type: String, required: true},
  role: String,
  organization_id: { type: String, ref: "Organization", required: true },
  start_date: String,
  end_date: String,

}, { strict: false, collection: 'posts' } );

PostSchema.virtual('url').get(function() {
  return '/' + this.constructor.collection.name + '/' + this._id;
});

"use strict"; 

var mongoose            = require('mongoose'),
    _                   = require('underscore'),
    Schema              = mongoose.Schema;

var PostSchema = module.exports = new Schema({
  _id: {
    type: String,
    default: function() {
      return (new mongoose.Types.ObjectId()).toHexString();
    }
  },

  label: { type: String, required: true},
  role: String,
  organization_id: { type: String, ref: "Organization", required: true },
  start_date: String,
  end_date: String,

}, { strict: false, collection: 'posts' } );

PostSchema.virtual('url').get(function() {
  return '/' + this.constructor.collection.name + '/' + this._id;
});

PostSchema.virtual('initials').get(function() {
  var words = this.label.split(' ');
  if (words.length > 1) {
    return words[0].slice(0, 1) + _.last(words).slice(0, 1);
  } else {
    return words[0].slice(0, 1);
  }
});

Add initials method to Post
Add initials method to Post

This doesn't really make sense for a post, need to come up with
something better to put here.
