Advertisement
Guest User

Untitled

a guest
Mar 13th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. var mongoose = require('mongoose');
  2. var Schema = mongoose.Schema;
  3.  
  4. var UserSchema = new Schema({
  5. username: String,
  6. password: String
  7. });
  8.  
  9. module.exports = mongoose.model('User', UserSchema);
  10.  
  11. var mongoose = require('mongoose');
  12. var Schema = mongoose.Schema;
  13.  
  14. var ChatroomSchema = new Schema({
  15. name: String,
  16. password: String,
  17. members: ???
  18. });
  19.  
  20. module.exports = mongoose.model('Chatroom', ChatroomSchema);
  21.  
  22. router.route('/chatroom')
  23. .post(function(req, res) {
  24. var chatroom = new Chatroom();
  25. chatroom.name = req.body.name;
  26. chatroom.password = encrypt(req.body.password,chatroom.name);
  27. chatroom.members = ???;
  28.  
  29. chatroom.save(function(err) {
  30. if (err)
  31. res.send(err);
  32.  
  33. res.json({ message: 'Chatroom created!' });
  34. });
  35. });
  36.  
  37. members : {username:String}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement