diff options
-rw-r--r-- | index.js | 3 | ||||
-rw-r--r-- | models/Movie.js | 14 | ||||
-rw-r--r-- | models/index.js | 3 |
3 files changed, 20 insertions, 0 deletions
@@ -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') +}; |