Created
July 8, 2014 18:29
-
-
Save nicholasess/300099a8e6e1cc5da890 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var studentModel = require('../models/Student'); | |
student_new: function(req, res){ | |
var student = new studentModel({ name: 'Nicholas' }); | |
student.save(function (err) { | |
if (err) // ... | |
console.log('CADASTROUUU'); | |
}); | |
res.render('admin/student/new'); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'), | |
db, | |
schema = mongoose.Schema;; | |
mongoose.connect('mongodb://localhost/moodle'); | |
db = mongoose.connection; | |
db.on('error', console.error); | |
db.once('open', function() { | |
console.log("mongo on"); | |
}); | |
var model = { | |
Schema: schema, | |
db: db | |
}; | |
module.exports = model; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('../lib/core/model'), | |
Schema = mongoose.Schema, | |
mongo = mongoose.db; | |
var student = new Schema({ | |
name: String | |
}) | |
module.exports = mongo.model('student', student); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment