Skip to content

Instantly share code, notes, and snippets.

@thebergamo
Last active August 29, 2015 14:03
Show Gist options
  • Save thebergamo/2c01084e07325b59cc4b to your computer and use it in GitHub Desktop.
Save thebergamo/2c01084e07325b59cc4b to your computer and use it in GitHub Desktop.
subdoc
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
//loading required Schemas
var departamentsSchema = mongoose.model('departments').schema;//require('./departaments');
var badgesSchema = mongoose.model('badges').schema; //require('./badges');
var permissionsSchema = mongoose.model('badges').schema;//require('./permissions');
//user schema
var userSchema = new Schema({
email: String,
name: {
first:String,
last: String
},
profile: {
born: Date,
otherInfo: String,
},
badges: [badgesSchema],
departments: [departamentsSchema],
permissions: [permissionsSchema]
});
mongoose.model('user', userSchema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment