Mongoose schema for Multi-User application

I'm using this collections for this part :

var permissions_schema = new mongoose.Schema({
    name : String,
    title : String
}); // this are mostly static data

var roles_schema = new mongoose.Schema({
    name : String,
    title : String,
    _permissions : Array
});// _permissions is an array that contain permissions _id

var contacts_schema = new mongoose.Schema({
    mobile : String,
    password : String,
    first_name : String,
    last_name : String,
    _role : Number,
    _enabled : Boolean,
    _deleted : Boolean,
    _verify_code : Number,
    _groups_id : Array,
    _service_id : String
}); // and at last _role is _id of the role which this user owns.

With something like these collections, you can manage your users easily. I hope these have good ideas for you.

UPDATE : A more flexible schema can have an Array of role_id in contact object, and contact can have many roles and his /her permissions are a merge of all roles permissions.


Here's the user schema from the MEAN.JS yeoman scaffolding generator:

    var UserSchema = new Schema({
    firstName: {
        type: String,
        trim: true,
        default: '',
        validate: [validateLocalStrategyProperty, 'Please fill in your first name']
    },
    lastName: {
        type: String,
        trim: true,
        default: '',
        validate: [validateLocalStrategyProperty, 'Please fill in your last name']
    },
    displayName: {
        type: String,
        trim: true
    },
    email: {
        type: String,
        trim: true,
        default: '',
        validate: [validateLocalStrategyProperty, 'Please fill in your email'],
        match: [/.+\@.+\..+/, 'Please fill a valid email address']
    },
    username: {
        type: String,
        unique: 'testing error message',
        required: 'Please fill in a username',
        trim: true
    },
    password: {
        type: String,
        default: '',
        validate: [validateLocalStrategyPassword, 'Password should be longer']
    },
    salt: {
        type: String
    },
    provider: {
        type: String,
        required: 'Provider is required'
    },
    providerData: {},
    additionalProvidersData: {},
    roles: {
        type: [{
            type: String,
            enum: ['user', 'admin']
        }],
        default: ['user']
    },
    updated: {
        type: Date
    },
    created: {
        type: Date,
        default: Date.now
    },
    /* For reset password */
    resetPasswordToken: {
        type: String
    },
    resetPasswordExpires: {
        type: Date
    }
});