Created
February 23, 2011 17:44
-
-
Save kernow/840796 to your computer and use it in GitHub Desktop.
mongoose find all
This file contains hidden or 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 sys = require('sys') | |
, mongoose = require('mongoose'); | |
mongoose.connect('mongodb://localhost/test_mongoose'); | |
// Models | |
var Schema = mongoose.Schema; | |
var UserSchema = new Schema({ | |
username : String | |
, uid : String | |
, messaged_on : Date | |
}); | |
mongoose.model('User', UserSchema); | |
var User = mongoose.model('User'); | |
// create a new user | |
var user = new User({ | |
uid : '54321' | |
, username : 'Bob' | |
, messaged_on : Date.now() | |
}); | |
user.save(); | |
User.find().all(function(user) { | |
sys.puts(user); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment