t_msgRcv.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //站内短信接收表
  2. var mongoose = require("./mongodb");
  3. var Schema = mongoose.Schema;
  4. var moment=require('moment');
  5. var msgRcvSchema = new Schema({
  6. smsID:{type: String,default:''},//smsID
  7. sendName:{type: String,default:''},//发送人
  8. rcvName:{type: String,default:''},//接收人
  9. title:{type: String,default:''},//发送标题
  10. content:{type: String,default:''},//发送消息
  11. time:{type: Date,default:Date.now},//接收时间
  12. read:{type: Number,default:0},//是否已读 默认0未读 ,1已读
  13. readTime:{type: Date,default:Date.now},//读取时间
  14. cancelled:{type: Number,default:0},//是否撤销 默认0未撤销 ,1已撤销
  15. cancelTime:{type: Date,default:Date.now},//撤销时间
  16. UPDATE_TIME:{type: Date,default:Date.now},//信息更新时间
  17. Deleted:{type: Number,default:0},//是否已删除
  18. },{
  19. strict: true,
  20. toObject: {
  21. virtuals: true
  22. },
  23. toJSON: {
  24. virtuals: true
  25. }
  26. }
  27. );
  28. msgRcvSchema.virtual('time2').get(function () {
  29. if(this.time =="")//判断传入的参数
  30. {
  31. return "";
  32. };
  33. return moment(this.time).format('YYYY-MM-DD HH:mm:ss');
  34. });
  35. msgRcvSchema.virtual('readTime2').get(function () {
  36. if(this.readTime =="")//判断传入的参数
  37. {
  38. return "";
  39. };
  40. return moment(this.readTime).format('YYYY-MM-DD HH:mm:ss');
  41. });
  42. msgRcvSchema.virtual('cancelTime2').get(function () {
  43. if(this.cancelTime == null)//判断传入的参数
  44. {
  45. return "";
  46. };
  47. return moment(this.cancelTime).format('YYYY-MM-DD HH:mm:ss');
  48. });
  49. msgRcvSchema.virtual('UPDATE_TIME2').get(function () {
  50. if(this.UPDATE_TIME =="")//判断传入的参数
  51. {
  52. return "";
  53. };
  54. return moment(this.UPDATE_TIME).format('YYYY-MM-DD HH:mm:ss');
  55. });
  56. var msgRcv = mongoose.model('msgRcv',
  57. msgRcvSchema,'t_msgRcv');
  58. module.exports = msgRcv;