Spaces:
Running
Running
Hozifaelgharbawy
commited on
Commit
·
f37be3f
1
Parent(s):
f3a868f
Create Templet Model and User model
Browse files
src/modules/common/Template/models/templet.ts
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mongoose from "mongoose";
|
2 |
+
const { Schema } = mongoose;
|
3 |
+
|
4 |
+
const templateSchema = new Schema({
|
5 |
+
name: { type: String, required: true, unique: true, dropDups: true },
|
6 |
+
user: { type: mongoose.Types.ObjectId, ref: "users" },
|
7 |
+
exercises: [{ type: mongoose.Types.ObjectId, ref: "exercises" }],
|
8 |
+
});
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
export const templateModel = mongoose.model("templates", templateSchema);
|
src/modules/common/User/models copy/templet.ts
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mongoose from "mongoose";
|
2 |
+
const { Schema } = mongoose;
|
3 |
+
|
4 |
+
const templateSchema = new Schema({
|
5 |
+
name: { type: String, required: true, unique: true, dropDups: true },
|
6 |
+
user: { type: mongoose.Types.ObjectId, ref: "users" },
|
7 |
+
exercises: [{ type: mongoose.Types.ObjectId, ref: "exercises" }],
|
8 |
+
});
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
export const templateModel = mongoose.model("templates", templateSchema);
|
src/modules/common/User/models/user.model.ts
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mongoose from "mongoose";
|
2 |
+
import bcrypt from "bcrypt";
|
3 |
+
export const saltrounds = 5;
|
4 |
+
const { Schema } = mongoose;
|
5 |
+
|
6 |
+
const userSchema = new Schema({
|
7 |
+
name: { type: String, required: true },
|
8 |
+
email: { type: String, required: true, unique: true, dropDups: true },
|
9 |
+
password: { type: String, required: true },
|
10 |
+
image: { type: Object, default: {} },
|
11 |
+
gender: { type: String, required: true },
|
12 |
+
height: { type: Number, required: true },
|
13 |
+
weight: { type: Number, required: true },
|
14 |
+
fitness_level: { type: Number, required: true },
|
15 |
+
preferences: {
|
16 |
+
fitness_goal: { type: Number, required: true },
|
17 |
+
target_weight: { type: Number, required: true },
|
18 |
+
workout_frequency: { type: Number, required: true },
|
19 |
+
preferred_days: [{ type: String, required: true }],
|
20 |
+
workout_place: { type: String, required: true },
|
21 |
+
preferred_equipments: { type: String, required: true }
|
22 |
+
},
|
23 |
+
injuries: [{ type: String, required: true }],
|
24 |
+
dob: { type: Date }
|
25 |
+
});
|
26 |
+
|
27 |
+
userSchema.pre("save", async function (next) {
|
28 |
+
this.password = await bcrypt.hash(this.password, saltrounds);
|
29 |
+
next();
|
30 |
+
});
|
31 |
+
|
32 |
+
export const userModel = mongoose.model("users", userSchema);
|