Skip to content

Instantly share code, notes, and snippets.

@raholland79
Created July 30, 2011 17:51
Show Gist options
  • Save raholland79/1115783 to your computer and use it in GitHub Desktop.
Save raholland79/1115783 to your computer and use it in GitHub Desktop.
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
mongoose.connect('mongodb://localhost/lol', function(err) {
if (err) { console.log(err) }
});
var ChatSchema = new Schema({
name: String
});
mongoose.model('Chat', ChatSchema);
var Chat = mongoose.model('Chat');
var n = new Chat();
n.name = "chat room";
n.save(function(err,room) {
console.log(room.id);
});
// run the file
$ node test.js
4e3444818cde747f02000001
$
mongoose 1.7.2
Mongo 1.8.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment