Skip to content
Open
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
27 changes: 26 additions & 1 deletion 8.MONGOOSE/1.Schema-Model/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,32 @@ const userProfileSchema = new mongoose.Schema({

//!3. Create the model
//? Compiling the schema
const User = mongoose.model("User", userProfileSchema); //users
const Student = mongoose.model("Student", studentsSchema);
//=====CREATE OPERATION======
//! ----.save()--------
const newUser = new User({
username: "masynctech",
age: 26,
birthday: new Date("2001-04-15"),
isActive: true,
hobbies: ["Soccer", "Reading", "Coding"],
address: {
street: "789 0ak St",
city: "Kumasi",
postaclCode: 5551,
},
customdata: {
country: "Ghana",
},
});

//! Save the doc
newUser
.save()
.then((data) => {
console.log(data);
})
.catch((error) => console.log(error));

//Start the server
app.listen(PORT, console.log(`Server is up and running on port ${PORT}`));