Advertisement
Guest User

Untitled

a guest
Apr 10th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. var notification = { type: data.notification_type, from: socket.request.user._id };
  2. notification = new Notification(notification);
  3.  
  4. User.update({ email: data.to }, { $push: { notifications: notification } }, function(err, model) {
  5. if (err) console.log(err);
  6. });
  7.  
  8. var UserSchema = new Schema({
  9. firstName: {
  10. type: String,
  11. trim: true,
  12. default: '',
  13. validate: [validateLocalStrategyProperty, 'Please fill in your first name']
  14. },
  15. lastName: {
  16. type: String,
  17. trim: true,
  18. default: '',
  19. validate: [validateLocalStrategyProperty, 'Please fill in your last name']
  20. },
  21. organization: {
  22. type: String,
  23. trim: true,
  24. default: '',
  25. required: 'Please fill in an organization name'
  26. },
  27. position: {
  28. type: String,
  29. trim: true,
  30. default: '',
  31. required: 'Please fill in the title of your position'
  32. },
  33. displayName: {
  34. type: String,
  35. trim: true
  36. },
  37. email: {
  38. type: String,
  39. trim: true,
  40. default: '',
  41. validate: [validateLocalStrategyProperty, 'Please fill in your email'],
  42. match: [/.+@.+..+/, 'Please fill a valid email address']
  43. },
  44. username: {
  45. type: String,
  46. unique: 'testing error message',
  47. required: 'Please fill in a username',
  48. trim: true
  49. },
  50. password: {
  51. type: String,
  52. default: '',
  53. validate: [validateLocalStrategyPassword, 'Password should be longer']
  54. },
  55. salt: {
  56. type: String
  57. },
  58. provider: {
  59. type: String,
  60. required: 'Provider is required'
  61. },
  62. providerData: {},
  63. additionalProvidersData: {},
  64. roles: {
  65. type: [{
  66. type: String,
  67. enum: ['user', 'admin']
  68. }],
  69. default: ['user']
  70. },
  71. updated: {
  72. type: Date
  73. },
  74. created: {
  75. type: Date,
  76. default: Date.now
  77. },
  78. /* For reset password */
  79. resetPasswordToken: {
  80. type: String
  81. },
  82. resetPasswordExpires: {
  83. type: Date
  84. },
  85. notifications: [{
  86. type: Schema.ObjectId,
  87. ref: 'Notifcation'
  88. }]
  89. });
  90.  
  91. var notification = { type: data.notification_type, from: socket.request.user._id };
  92. notification = new Notification(notification);
  93.  
  94. User.findOneAndUpdate(
  95. { email: data.to },
  96. { $push:
  97. { notifications: notification }
  98. },
  99. function(err, model) {
  100. if (err) console.log(err);
  101. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement