Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadammmoura committed May 23, 2021
1 parent b6e8def commit 3527183
Show file tree
Hide file tree
Showing 4 changed files with 1,308 additions and 2 deletions.
28 changes: 28 additions & 0 deletions controller/user.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const userMod = require("../module/users.module");

const addNewUser = async (req, res) => {
try {
const { email } = req.body;

const newUse = new userMod.UserModel({
email: email,
});

await newUse.save();
res.send("done");
} catch (err) {
console.log(err);
res.send("this account is here");
}

};

// const sufian = new UserModel({
// email: 'sufian.hamdan.1992.94@gmail.com',
// movies: [{name: 'asdasdasdasd', description: 'klaskfnanma', year: '04-11-2000', duration: '190'}]

// });

module.exports = {
addNewUser: addNewUser,
};
6 changes: 5 additions & 1 deletion module/users.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ const mongoose = require('mongoose');
const movie = require ('./movie.module');

const UserSchema = new mongoose.Schema({
email: String,
email: {
type: String,
unique: true // `email` must be unique
},
movies: [movie.MovieSchema]
});


const UserModel = mongoose.model('user', UserSchema);

const sufian = new UserModel({
email: 'sufian.hamdan.1992.94@gmail.com',
movies: [{name: 'asdasdasdasd', description: 'klaskfnanma', year: '04-11-2000', duration: '190'}]
Expand Down
Loading

0 comments on commit 3527183

Please sign in to comment.