Created
October 19, 2012 20:32
-
-
Save nathanbowser/3920556 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 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