Skip to content

Commit 3a9b9ee

Browse files
committed
add models
1 parent 376de33 commit 3a9b9ee

14 files changed

Lines changed: 492 additions & 2 deletions

backend/src/models/award.model.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import mongoose from "mongoose";
2+
3+
const awardSchema = new mongoose.Schema(
4+
{
5+
name: {
6+
type: String,
7+
required: true,
8+
trim: true,
9+
},
10+
type: {
11+
type: String,
12+
enum: [
13+
"SiteOfTheDay",
14+
"ProjectOfTheWeek",
15+
"InnovationAward",
16+
"CommunityChoice",
17+
],
18+
required: true,
19+
},
20+
projectId: {
21+
type: mongoose.Schema.Types.ObjectId,
22+
ref: "Project",
23+
},
24+
developerId: {
25+
type: mongoose.Schema.Types.ObjectId,
26+
ref: "User",
27+
},
28+
year: {
29+
type: Number,
30+
},
31+
},
32+
{ timestamps: true }
33+
);
34+
35+
const Award = mongoose.model("Award", awardSchema);
36+
37+
export default Award;

backend/src/models/cart.model.js

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import mongoose from "mongoose";
2+
3+
const categorySchema = new mongoose.Schema(
4+
{
5+
name: {
6+
type: String,
7+
required: true,
8+
trim: true,
9+
unique: true,
10+
},
11+
description: {
12+
type: String,
13+
trim: true,
14+
},
15+
},
16+
{ timestamps: true }
17+
);
18+
19+
const Category = mongoose.model("Category", categorySchema);
20+
21+
export default Category;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import mongoose from "mongoose";
2+
3+
const clientProfileSchema = new mongoose.Schema(
4+
{
5+
userId: {
6+
type: mongoose.Schema.Types.ObjectId,
7+
ref: "User",
8+
required: true,
9+
unique: true,
10+
index: true,
11+
},
12+
companyName: {
13+
type: String,
14+
trim: true,
15+
},
16+
industry: {
17+
type: String,
18+
trim: true,
19+
},
20+
companySize: {
21+
type: String,
22+
trim: true,
23+
},
24+
website: {
25+
type: String,
26+
trim: true,
27+
},
28+
location: {
29+
type: String,
30+
trim: true,
31+
},
32+
description: {
33+
type: String,
34+
trim: true,
35+
},
36+
},
37+
{ timestamps: true }
38+
);
39+
40+
const ClientProfile = mongoose.model("ClientProfile", clientProfileSchema);
41+
42+
export default ClientProfile;
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import mongoose from "mongoose";
2+
3+
const developerProfileSchema = new mongoose.Schema(
4+
{
5+
userId: {
6+
type: mongoose.Schema.Types.ObjectId,
7+
ref: "User",
8+
required: true,
9+
unique: true,
10+
index: true,
11+
},
12+
title: {
13+
type: String,
14+
trim: true,
15+
},
16+
bio: {
17+
type: String,
18+
trim: true,
19+
},
20+
skills: [
21+
{
22+
type: String,
23+
trim: true,
24+
},
25+
],
26+
technologies: [
27+
{
28+
type: mongoose.Schema.Types.ObjectId,
29+
ref: "Technology",
30+
},
31+
],
32+
experienceYears: {
33+
type: Number,
34+
min: 0,
35+
},
36+
hourlyRate: {
37+
type: Number,
38+
min: 0,
39+
},
40+
availability: {
41+
type: String,
42+
trim: true,
43+
},
44+
portfolioProjects: [
45+
{
46+
type: mongoose.Schema.Types.ObjectId,
47+
ref: "Project",
48+
},
49+
],
50+
awards: [
51+
{
52+
type: mongoose.Schema.Types.ObjectId,
53+
ref: "Award",
54+
},
55+
],
56+
rating: {
57+
type: Number,
58+
default: 0,
59+
min: 0,
60+
max: 5,
61+
},
62+
totalReviews: {
63+
type: Number,
64+
default: 0,
65+
min: 0,
66+
},
67+
location: {
68+
type: String,
69+
trim: true,
70+
},
71+
github: {
72+
type: String,
73+
trim: true,
74+
},
75+
linkedin: {
76+
type: String,
77+
trim: true,
78+
},
79+
website: {
80+
type: String,
81+
trim: true,
82+
},
83+
},
84+
{ timestamps: true }
85+
);
86+
87+
developerProfileSchema.index({ skills: 1 });
88+
89+
const DeveloperProfile = mongoose.model(
90+
"DeveloperProfile",
91+
developerProfileSchema
92+
);
93+
94+
export default DeveloperProfile;

backend/src/models/match.model.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import mongoose from "mongoose";
2+
3+
const matchSchema = new mongoose.Schema(
4+
{
5+
projectRequestId: {
6+
type: mongoose.Schema.Types.ObjectId,
7+
ref: "ProjectRequest",
8+
required: true,
9+
},
10+
developerId: {
11+
type: mongoose.Schema.Types.ObjectId,
12+
ref: "User",
13+
required: true,
14+
},
15+
score: {
16+
type: Number,
17+
min: 0,
18+
max: 100,
19+
required: true,
20+
},
21+
reason: {
22+
type: String,
23+
trim: true,
24+
},
25+
},
26+
{ timestamps: true }
27+
);
28+
29+
matchSchema.index({ projectRequestId: 1 });
30+
31+
const Match = mongoose.model("Match", matchSchema);
32+
33+
export default Match;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import mongoose from "mongoose";
2+
3+
const messageSchema = new mongoose.Schema(
4+
{
5+
senderId: {
6+
type: mongoose.Schema.Types.ObjectId,
7+
ref: "User",
8+
required: true,
9+
},
10+
receiverId: {
11+
type: mongoose.Schema.Types.ObjectId,
12+
ref: "User",
13+
required: true,
14+
},
15+
projectRequestId: {
16+
type: mongoose.Schema.Types.ObjectId,
17+
ref: "ProjectRequest",
18+
},
19+
message: {
20+
type: String,
21+
required: true,
22+
trim: true,
23+
},
24+
attachments: [
25+
{
26+
type: String,
27+
trim: true,
28+
},
29+
],
30+
},
31+
{ timestamps: true }
32+
);
33+
34+
const Message = mongoose.model("Message", messageSchema);
35+
36+
export default Message;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import mongoose from "mongoose";
2+
3+
const notificationSchema = new mongoose.Schema(
4+
{
5+
userId: {
6+
type: mongoose.Schema.Types.ObjectId,
7+
ref: "User",
8+
required: true,
9+
},
10+
type: {
11+
type: String,
12+
enum: [
13+
"NEW_PROJECT_MATCH",
14+
"PROJECT_REQUEST",
15+
"NEW_MESSAGE",
16+
"AWARD_RECEIVED",
17+
],
18+
required: true,
19+
},
20+
message: {
21+
type: String,
22+
required: true,
23+
trim: true,
24+
},
25+
isRead: {
26+
type: Boolean,
27+
default: false,
28+
},
29+
},
30+
{ timestamps: true }
31+
);
32+
33+
const Notification = mongoose.model("Notification", notificationSchema);
34+
35+
export default Notification;

backend/src/models/order.model.js

Whitespace-only changes.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import mongoose from "mongoose";
2+
3+
const projectSchema = new mongoose.Schema(
4+
{
5+
title: {
6+
type: String,
7+
required: true,
8+
trim: true,
9+
},
10+
description: {
11+
type: String,
12+
required: true,
13+
trim: true,
14+
},
15+
developerId: {
16+
type: mongoose.Schema.Types.ObjectId,
17+
ref: "User",
18+
required: true,
19+
},
20+
category: {
21+
type: mongoose.Schema.Types.ObjectId,
22+
ref: "Category",
23+
},
24+
technologies: [
25+
{
26+
type: mongoose.Schema.Types.ObjectId,
27+
ref: "Technology",
28+
},
29+
],
30+
images: [
31+
{
32+
type: String,
33+
trim: true,
34+
},
35+
],
36+
liveDemo: {
37+
type: String,
38+
trim: true,
39+
},
40+
githubRepo: {
41+
type: String,
42+
trim: true,
43+
},
44+
awards: [
45+
{
46+
type: mongoose.Schema.Types.ObjectId,
47+
ref: "Award",
48+
},
49+
],
50+
views: {
51+
type: Number,
52+
default: 0,
53+
min: 0,
54+
},
55+
likes: {
56+
type: Number,
57+
default: 0,
58+
min: 0,
59+
},
60+
},
61+
{ timestamps: true }
62+
);
63+
64+
projectSchema.index({ technologies: 1 });
65+
66+
const Project = mongoose.model("Project", projectSchema);
67+
68+
export default Project;

0 commit comments

Comments
 (0)