Skip to content

Instantly share code, notes, and snippets.

@nathanbowser
Created October 19, 2012 20:32
Show Gist options
  • Save nathanbowser/3920556 to your computer and use it in GitHub Desktop.
Save nathanbowser/3920556 to your computer and use it in GitHub Desktop.
var http = require('http')
, mongoose = require('mongoose')
, Schema = mongoose.Schema
var conn = mongoose.connect('mongodb://localhost/mongoose_test')
var names = ('Nathan Kristina Linus').split(' ')
var Person = new Schema({
name: String
});
var collection = 'people'
mongoose.model('Person', Person)
var people = names.map(function (name) {
return { name: name }
})
mongoose.model('Person').create(people, function (err,s) {
console.log(err, s)
})
http.createServer(function (req, res) {
mongoose.model('Person').find().stream().pipe(res)
}).listen(1337, '127.0.0.1')
console.log('Server running at http://127.0.0.1:1337/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment