Skip to content

Commit

Permalink
database setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadammmoura committed May 21, 2021
1 parent 42b453f commit e70a148
Show file tree
Hide file tree
Showing 9 changed files with 1,571 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
PORT=
PORT=8081
DATABASE_URL=27017
8 changes: 8 additions & 0 deletions controller/index.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const homePage = (req, res) => {
res.send('Mema3aaaaaaaaaaaaaaa');
}


module.exports = {
homePage:homePage
}
17 changes: 17 additions & 0 deletions module/actors.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@


const mongoose = require("mongoose");

const actorSchema = new mongoose.Schema({
name: String,
birthday:String,
actorPic:String
// actorMovies:[]
});
const actorSchema = mongoose.model("movies", actorSchema);


module.exports = {
actorSchema:actorSchema,
actorSchema:actorSchema
};
18 changes: 18 additions & 0 deletions module/movie.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

"use strict";

const mongoose = require("mongoose");
const actors = require('./actors.module')

const movieSchema = new mongoose.Schema({
name: String,
description: String,
year: String,
actors:[actors.actorSchema]
});
const moviesModel = mongoose.model("movies", movieSchema);

module.exports = {
movieSchema: movieSchema,
moviesModel: moviesModel,
};
Empty file removed module/users.model.js
Empty file.
19 changes: 19 additions & 0 deletions module/users.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const mongoose = require('mongoose');
mongoose.connect(`mongodb://localhost:${process.env.DATABASE_URL}/movies`, {useNewUrlParser: true, useUnifiedTopology: true});

const movie = require('./movie.module')

const user = new mongoose.Schema({
Email: String,
movies: [movie.bookSchema]
});


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




module.exports = {
UserModel:UserModel
};
Loading

0 comments on commit e70a148

Please sign in to comment.