Created
November 7, 2012 02:55
-
-
Save mfrobben/4029328 to your computer and use it in GitHub Desktop.
Mongoose stuff
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 mongoose = require('mongoose'), | |
Schema = mongoose.Schema, | |
var User = new Schema({ | |
email : { type : String, required: true, unique: true }, | |
firstName: { type : String} | |
// and so on | |
}) | |
exports.User = mongoose.model('User', User) |
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 User = require(__dirname + '/../models/user').User | |
User.findOne({email : req.query.email}, function(err, user){ | |
if (err) | |
return res.send(500, errors.databaseError) | |
//can use user here | |
} | |
// You can also do var myuser = new User() | |
// then set attributes and call myuser.save() to insert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment