Created
December 2, 2012 18:54
-
-
Save dileephell/4190424 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 db = require('../lib/db'); | |
var UserSchema = new db.Schema({ | |
username : {type: String, unique: true} | |
, password : String | |
}) | |
var MyUser = db.mongoose.model('User', UserSchema); | |
// Exports | |
module.exports.addUser = addUser; | |
// Add user to database | |
function addUser(username, password, callback) { | |
var instance = new MyUser(); | |
instance.username = username; | |
instance.password = password; | |
instance.save(function (err) { | |
if (err) { | |
callback(err); | |
} | |
else { | |
callback(null, instance); | |
} | |
}); | |
} | |
We |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment