Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/model/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

const mongoose = require("mongoose");

const EventSchema = new mongoose.Schema(
{
title: {
type: String,
trim: true,
},
eventDate : {
type : Date,
required : false
},
proposedStartDate: {
type: Date,
required: true,
},
proposedEndDate: {
type: Date,
required:true
},
hostProposedEndDate: {
type: Date,
required:true
},
hostProposedEndDate: {
type: Date,
required:true
},
},
{
timestamps: true
}
);


// Export the model
module.exports = mongoose.model("Event", EventSchema);
33 changes: 33 additions & 0 deletions src/model/participate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

const mongoose = require("mongoose");

const ParticipateSchema = new mongoose.Schema(
{

event_id: {
type: mongoose.Types,
ref: 'Event',
required: true
},
eventType: {
type: String,
trim: true,
},
proposedStartDate: {
type: Date,
required: true,
},
proposedEndDate: {
type: Date,
required: true
},

},
{
timestamps: true
}
);


// Export the model
module.exports = mongoose.model("Participate", ParticipateSchema);
44 changes: 44 additions & 0 deletions src/model/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const bcrypt = require("bcrypt");
const { BCRYPT_SALT } = process.env;
const mongoose = require("mongoose");

const UserSchema = new mongoose.Schema(
{
goggleId: {
type: String,
trim: true,
required: false,
},
signup_type : {
type : String,
trim : true,
enum : ["email", "third-party"],
default : "email",
required : true
},
email: {
type: String,
trim: true,
unique: true,
required: [true, "Email is required"],
},
password: {
type: String,
},
},
{
timestamps: true
}
);

UserSchema.pre("save", async function (next) {
if (!this.isModified('password')) return next()

const hash = await bcrypt.hash(this.password, parseInt(BCRYPT_SALT));
this.password = hash;

next();
});

// Export the model
module.exports = mongoose.model("User", UserSchema);