Skip to content

Commit

Permalink
Add mongoose chat model
Browse files Browse the repository at this point in the history
  • Loading branch information
Divy Srivastava committed Jun 5, 2019
1 parent 382cef5 commit 8578cbc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
7 changes: 4 additions & 3 deletions bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ var server = http.createServer(app);
/**
* Create websocket server
*/

var io = require('socket.io')(server);

io.on('connection', (client) => {
client.on('typing', function (data) {
// ToDo
})
});
client.on('send', function (data) {
// ToDo
})
})
});
});

/**
* Listen on provided port, on all network interfaces.
Expand Down
6 changes: 3 additions & 3 deletions utils/models/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');
// define the schema for our user model
var chatSchema = mongoose.Schema({
users:String,
chats:Array
users:Array, // ["John", "Doe"]
chats:Array // {txt:"Hi", by:"john", time:"10:35pm"}
});


module.exports = mongoose.model('room', chatSchema);

// create the model for users and expose it to our app
// create the model for users and expose it to our app
23 changes: 12 additions & 11 deletions utils/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');
// define the schema for our user model
var userSchema = mongoose.Schema({
username:String,
password: String,
firstname: String,
lastname: String,
bio: String,
dob: String,
followers: Array,
posts:Array,
profile_pic:String,
lastLogin:String
username:String, // _username_
password: String, // 123rikwdjbfp2ioeurroasodfj[OJ[Ojsjdfag*wef
firstname: String, // firstName
lastname: String, // lastName
bio: String, // A new bio
dob: String, // 23rd july 2018
followers: Array, // ["134wr3","1q2easd2"]
posts:Array,
profile_pic:String, // /public/profile_pic/username/user.png
chat_rooms:Array, // ["1234", "3456"]
lastLogin:String // 10 min ago
});

// methods ======================
Expand All @@ -29,4 +30,4 @@ userSchema.methods.validPassword = function(password) {

module.exports = mongoose.model('user', userSchema);

// create the model for users and expose it to our app
// create the model for users and expose it to our app

0 comments on commit 8578cbc

Please sign in to comment.