Source: lib/profile.js

'use strict';

/**
 * Подробный профиль
 *
 * Базовая схема для всех элементов системы
 * Изменение данной схемы влияет на все элементы системы
 *
 */
var debug = require('debug')('models:profile');
var mongoose = require('mongoose');
var extend = require('mongoose-schema-extend');
var Schema = mongoose.Schema;
var parentModel = require('./thing');

var Model = function () {

  var Parent = mongoose.model('Thing').schema;

  /**
   * Главная базовая схема для создания профиля
   * пользователя в системе. У каждого аккаунта в системе
   * может быть множество профилей. Например один аккаунт может
   * управлять персональным профилем и профилем организации.
   *
   * @class Profile
   * @augments Thing
   * @version 0.0.1
   *
   * @see {@link Account}
   * @see {@link Thing}
   *
   */
  var _Schema = Parent.extend(
    /** @lends Profile.prototype */
    {

      /**
       * Тип пользователя. (manager, sponsor, member etc.)
       */
      memberType: [],

      /**
       * Тип аккаунтаб (free, vip, private etc.)
       */
      accountType: [],

      /**
       * Тип профиля
       */
      profileType: [] // etc
    },
    {
      /**
       * Имя коллекции
       */
      collection: 'profiles',
      /**
       * Ключ по которому будут различатся записи
       * обычно соответствует имени Схемы
       */
      discriminatorKey: '_type'
    }
  );

  return mongoose.model('Profile', _Schema);

};

module.exports = new Model();