Skip to content

Commit 2ac820c

Browse files
committed
adding the std bank schema and updating the syntax
of the files
1 parent 691e9f5 commit 2ac820c

File tree

1 file changed

+6
-61
lines changed

1 file changed

+6
-61
lines changed

models/std_college.js

Lines changed: 6 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { connector } = require("./databaseUtil");
22

3-
const CollegeSchema = {
3+
const StudentCollegeSchema = {
44
userId: {
55
type: String,
66
required: true,
@@ -60,64 +60,9 @@ const CollegeSchema = {
6060
},
6161
};
6262

63-
const College = new connector.model("College", CollegeSchema);
63+
const studentcollegeCollege = new connector.model(
64+
"StudentCollegeSchema",
65+
StudentCollegeSchema
66+
);
6467

65-
export const AddCollegeDetails = async (req, res) => {
66-
const id = req.body.id;
67-
const newCollegeDetails = new College({
68-
userId: id,
69-
...req.body,
70-
});
71-
try {
72-
const data = await College.findById(id);
73-
if (data)
74-
return res.status(400).send("One user can have only one college details");
75-
76-
await newCollegeDetails.save();
77-
res.status(201).send("user has been created");
78-
} catch (error) {
79-
console.log(error);
80-
}
81-
};
82-
export const GetCollegeDetails = async (req, res) => {
83-
const id = req.params.id;
84-
try {
85-
const data = await College.findById(id);
86-
if (!data)
87-
return res
88-
.status(400)
89-
.send("No data found for this id please add your data");
90-
91-
res.status(200).json(data);
92-
} catch (error) {
93-
console.log(error);
94-
}
95-
};
96-
97-
export const updateCollegeDetails = async (req, res) => {
98-
const id = req.body.id;
99-
try {
100-
const finddata = await College.findById(id);
101-
if (!finddata) res.status(404).send("No data found for this user");
102-
103-
const data = await College.findByIdAndUpdate(
104-
req.params.id,
105-
{ $set: req.body },
106-
{ new: true }
107-
);
108-
console.log(data);
109-
} catch (error) {
110-
console.log(error);
111-
}
112-
};
113-
export const deleteCollegeDetails = async (req, res) => {
114-
const id = req.body.id;
115-
try {
116-
const finddata = await College.findById(id);
117-
if (!finddata) res.status(404).send("No data found for this user");
118-
await College.findByIdAndDelete(req.params.id);
119-
res.status(200).send("details deleted successfully");
120-
} catch (error) {
121-
console.log(error);
122-
}
123-
};
68+
module.exports = {};

0 commit comments

Comments
 (0)