summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-06-02 16:35:02 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-06-02 16:35:02 +0200
commitb67a8a67c30c8f0e172450e09f3699fc0b7667e9 (patch)
tree1b88307e03e3d777c502b2b3e001e1392a6c9305
parent3f37aa7e9569ee130ff8b1e8996158737a7cb379 (diff)
downloadmean-app-b67a8a67c30c8f0e172450e09f3699fc0b7667e9.zip
mean-app-b67a8a67c30c8f0e172450e09f3699fc0b7667e9.tar.gz
add and require models/Movie
-rw-r--r--index.js3
-rw-r--r--models/Movie.js14
-rw-r--r--models/index.js3
3 files changed, 20 insertions, 0 deletions
diff --git a/index.js b/index.js
index 329f86f..91dbd21 100644
--- a/index.js
+++ b/index.js
@@ -30,6 +30,9 @@ app.use('/hello', function(req, res, next) {
// connect to mongodb
mongoose.connect('mongodb://localhost/meanapp');
mongoose.connection.once('open', function() {
+
+ app.models = require('./models/index.js');
+
console.log("listening on port " + port);
app.listen(port);
});
diff --git a/models/Movie.js b/models/Movie.js
new file mode 100644
index 0000000..ad6dca1
--- /dev/null
+++ b/models/Movie.js
@@ -0,0 +1,14 @@
+var mongoose = require('mongoose');
+
+var MovieSchema = new mongoose.Schema({
+ title: {
+ type: String,
+ required: true
+ },
+ url: {
+ type: String,
+ required: true
+ }
+});
+
+module.exports = mongoose.model('movie', MovieSchema);
diff --git a/models/index.js b/models/index.js
new file mode 100644
index 0000000..7a7f208
--- /dev/null
+++ b/models/index.js
@@ -0,0 +1,3 @@
+module.exports = {
+ movie: require('./Movie')
+};