Skip to content

Commit

Permalink
adb
Browse files Browse the repository at this point in the history
  • Loading branch information
SufianHamdan committed May 23, 2021
1 parent 0cd0022 commit f3fac83
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 1,383 deletions.
110 changes: 55 additions & 55 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
{
"globals": {
"Mustache": true,
"$": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 6
},
"env": {
"browser": true,
"es6": true,
"jest": true,
"jquery": true,
"node": true
},
"rules": {
"eol-last": "error",
"eqeqeq": [
"error",
"always"
],
"indent": [
"error",
2
],
"new-cap": "warn",
"no-console": "off",
"no-multi-spaces": [
"warn",
{
"exceptions": {
"VariableDeclarator": true
}
}
],
"no-redeclare": [
"error",
{
"builtinGlobals": true
}
],
"no-template-curly-in-string": "error",
"no-trailing-spaces": "warn",
"no-undefined": "off",
"quotes": [
"warn",
"single",
{
"allowTemplateLiterals": true
}
],
"semi": "error"
}
}
// {
// "globals": {
// "Mustache": true,
// "$": true
// },
// "extends": "eslint:recommended",
// "parserOptions": {
// "ecmaVersion": 6
// },
// "env": {
// "browser": true,
// "es6": true,
// "jest": true,
// "jquery": true,
// "node": true
// },
// "rules": {
// "eol-last": "error",
// "eqeqeq": [
// "error",
// "always"
// ],
// "indent": [
// "error",
// 2
// ],
// "new-cap": "warn",
// "no-console": "off",
// "no-multi-spaces": [
// "warn",
// {
// "exceptions": {
// "VariableDeclarator": true
// }
// }
// ],
// "no-redeclare": [
// "error",
// {
// "builtinGlobals": true
// }
// ],
// "no-template-curly-in-string": "error",
// "no-trailing-spaces": "warn",
// "no-undefined": "off",
// "quotes": [
// "warn",
// "single",
// {
// "allowTemplateLiterals": true
// }
// ],
// "semi": "error"
// }
// }
16 changes: 9 additions & 7 deletions controller/movies.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@ const UserModel = require('../module/users.module');

const getMovies = async (req, res) => {
const { email } = req.query;
console.log (email);
await UserModel.find({ email: email }, function (err, userData) {
console.log (req.query);
await UserModel.UserModel.find({ email: email }, function (err, userData) {
if (err) res.send('didnt work');
res.send(userData);
res.send(userData[0]);
});
}

const addMovie = async (request, response) => {
const { email, movieName, movieDescription, movieYear} = request.body;
await UserModel.find({ email: email }, (error, userData) => {
// console.log(userData);
console.log(request.body);
await UserModel.UserModel.find({ email: email }, (error, userData) => {
userData[0].movies.push({
name: movieName,
description: movieDescription,
year: movieYear
});
userData[0].save();

response.send(userData);

});
}

Expand All @@ -30,9 +32,9 @@ const deleteMovieForEmail= async (req, res) => {
console.log(req.params);

const { email } = req.query;
await UserModel.find({ email: email }, (err, userData) => {
await UserModel.UserModel.find({ email: email }, (err, userData) => {

const newMoviesArr = userData[0].books.filter((user, idx) => {
const newMoviesArr = userData[0].movies.filter((user, idx) => {
return idx !== index;
});
userData[0].movies = newMoviesArr;
Expand Down
3 changes: 2 additions & 1 deletion module/movie.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const MovieSchema = new mongoose.Schema({
name: String,
description: String,
year: String,
actors: [actors.ActorSchema]
duration: String,
// actors: [actors.ActorSchema]
});
const MoviesModel = mongoose.model('movie', MovieSchema);

Expand Down
9 changes: 9 additions & 0 deletions module/users.module.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
const mongoose = require('mongoose');
// const { getMaxListeners } = require('superagent');
const movie = require ('./movie.module');

const UserSchema = new mongoose.Schema({
Expand All @@ -9,6 +10,14 @@ const UserSchema = new mongoose.Schema({


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'}]

});

// sufian.save();


module.exports = {
UserModel: UserModel
Expand Down
Loading

0 comments on commit f3fac83

Please sign in to comment.