Skip to content

Instantly share code, notes, and snippets.

@fredrick
Created February 1, 2012 05:46
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 fredrick/1715359 to your computer and use it in GitHub Desktop.
Save fredrick/1715359 to your computer and use it in GitHub Desktop.
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