Skip to content

Instantly share code, notes, and snippets.

@dileephell
Created December 2, 2012 18:54
Show Gist options
  • Save dileephell/4190424 to your computer and use it in GitHub Desktop.
Save dileephell/4190424 to your computer and use it in GitHub Desktop.
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