GlobalNotificationSetting.js 1018 B

1234567891011121314151617181920212223242526
  1. const debug = require('debug')('growi:models:GlobalNotificationSetting');
  2. const mongoose = require('mongoose');
  3. const notificationSchema = require('./GlobalNotificationSetting/GlobalNotificationSettingParentSchema');
  4. const GlobalNotificationSettingClass = require('./GlobalNotificationSetting/GlobalNotificationSettingClass');
  5. /**
  6. * create child schemas inherited from parentSchema
  7. * all child schemas are stored in globalnotificationsettings collection
  8. * @link{http://url.com module_name}
  9. * @param {object} parentSchema
  10. * @param {string} modelName
  11. * @param {string} discriminatorKey
  12. */
  13. const createChildSchemas = (parentSchema, modelName, discriminatorKey) => {
  14. const Notification = mongoose.model(modelName, parentSchema);
  15. return {
  16. Parent: Notification,
  17. };
  18. };
  19. module.exports = function(crowi) {
  20. GlobalNotificationSettingClass.crowi = crowi;
  21. notificationSchema.loadClass(GlobalNotificationSettingClass);
  22. return createChildSchemas(notificationSchema, 'GlobalNotificationSetting', 'type');
  23. };