surrsoft
10/4/2019 - 1:26 PM

index.js

const repositories = {
  Agent: require('./Agent'),
  Client: require('./Client'),
  User: require('./User'),
  Settings: require('./Settings'),
  Template: require('./Template'),
  Deployment: require('./Deployment'),
  Application: require('./Application'),
  Category: require('./Category'),
  AppInstance: require('./AppInstance'),
  ActionApp: require('./ActionApp'),
  WebHook: require('./WebHook'),
  BotLog: require('./BotLog'),
  UserRole: require('./UserRole'),
  Automation: require('./Automation'),
  AutomationTask: require('./AutomationTask'),
  AutomationLog: require('./AutomationLog'),
};

function createModelRepository(modelName, context) {
  const model = context.models[modelName];
  return repositories[modelName] ? new repositories[modelName](context) : context[modelName]; // todo change to model?
}

module.exports = {
  createModelRepository,
};