Skip to content

Instantly share code, notes, and snippets.

@fredrick fredrick/models.js

Created Feb 1, 2012
Embed
What would you like to do?
Handling multipart events in Mongoose Query callback?
var mongoose = require('mongoose');
function User() {
return mongoose.model('users', new mongoose.Schema({
username: String,
email: String,
name: String
}));
}
exports = module.exports = User;
/** Example HTTP server
*/
var http = require('http'),
mongoose = require('mongoose'),
formidable = require('formidable'),
models = require('./models');
mongoose.connect('mongodb://localhost/test');
var User = new models.User();
var form = new formidable.IncomingForm();
http.createServer(function(request, response) {
User.findOne({ username: 'wayoutmind' }, function(error, user) {
// Does not print to console, Event listener blackhole?
form.on('field', function(name, value) {
console.log(name + ':' + value);
});
form.parse(request);
});
}).listen(1337);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.