Skip to content

Instantly share code, notes, and snippets.

@johannesboyne
Created January 10, 2014 06:39
Show Gist options
  • Save johannesboyne/8347861 to your computer and use it in GitHub Desktop.
Save johannesboyne/8347861 to your computer and use it in GitHub Desktop.
// User
// ====
var UserSchema = mongoose.Schema({
username: String,
email: String,
salt: String,
hashed_password: String,
orgas: [{type: mongoose.Schema.ObjectId, ref: 'Organization'}]
});
// [...] all kind of User methods like:
UserSchema.virtual('id')
.get(function() {
return this._id.toHexString();
});
// Organization
// ============
var OrganizationSchema = mongoose.Schema({
name: String,
members: [{type: mongoose.Schema.ObjectId, ref: 'User'}],
});
exports.User = mongoose.model('User', UserSchema);
exports.Organization = mongoose.model('Organization', OrganizationSchema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment