Skip to content

Instantly share code, notes, and snippets.

@nicholasess
Created July 8, 2014 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicholasess/300099a8e6e1cc5da890 to your computer and use it in GitHub Desktop.
Save nicholasess/300099a8e6e1cc5da890 to your computer and use it in GitHub Desktop.
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');
},
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;
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