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

var MessageSchema = new Schema({
  room_id: String,
  creator: {
    user_id: String,
    user_name: String,
  },
  date: { type: Date, default: Date.now },
  content: String
});

MessageSchema.methods.getTime = function() {
  var d = this._id ? this._id.getTimestamp() : "message not exist!";
  return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+" "+d.getHours()+ ":"+d.getMinutes()+ ":"+d.getSeconds()
}

module.exports = MessageSchema;