Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var RoomSchema = new Schema({
- _creator: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
- name: { type: String, required: true},
- pass: { type: String, required: true}
- });
- // Scheme for the users of the mongodb
- var UserSchema = new Schema({
- email: { type: String, required: true },
- password: { type: String, required: true},
- username: { type: String, required: false },
- appRooms: [ { type: Schema.Types.ObjectId, ref: 'Room' } ]
- });
- UserSchema.set('collection', 'users');
- RoomSchema.set('collection', 'rooms');
- UserSchema.methods.comparePassword = function(candidatePassword, cb) {
- bcrypt.compare(candidatePassword, this.password, function(err, isMatch) {
- if (err) return cb(err);
- cb(null, isMatch);
- });
- };
- exports.User = mongoose.model('User', UserSchema);
- exports.Room = mongoose.model('Room', RoomSchema);
- exports.mongourl = mongourl;
- exports.mongoose = mongoose
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement