@storehouse/sequelize - v2.0.0
    Preparing search index...

    Function getModel

    • Retrieves a Sequelize model from the registry.

      Type Parameters

      • M extends Model<any, any> = Model<any, any>

        The Model type to return, defaults to Model

      Parameters

      • registry: Registry

        The Storehouse registry containing registered managers

      • modelName: string

        The name of the model to retrieve

      Returns ModelStatic<M>

      The requested ModelStatic instance

      If the model is not found in the registry

      const User = getModel(registry, 'User');
      const users = await User.findAll();
    • Retrieves a Sequelize model from a specific manager in the registry.

      Type Parameters

      • M extends Model<any, any> = Model<any, any>

        The Model type to return, defaults to Model

      Parameters

      • registry: Registry

        The Storehouse registry containing registered managers

      • managerName: string

        The name of the manager to retrieve the model from

      • modelName: string

        The name of the model to retrieve

      Returns ModelStatic<M>

      The requested ModelStatic instance

      If the model is not found in the specified manager

      const User = getModel(registry, 'primary-db', 'User');
      const user = await User.findByPk(1);
    • Retrieves a Sequelize model from the registry.

      Type Parameters

      • M extends ModelStatic<Model<any, any>> = ModelStatic<Model<any, any>>

        The Model type to return, defaults to Model

      Parameters

      • registry: Registry

        The Storehouse registry containing registered managers

      • modelName: string

        The name of the model to retrieve

      Returns M

      The requested ModelStatic instance

      If the model is not found in the registry

      const User = getModel(registry, 'User');
      const users = await User.findAll();
    • Retrieves a Sequelize model from the registry.

      Type Parameters

      • M extends ModelStatic<Model<any, any>> = ModelStatic<Model<any, any>>

        The Model type to return, defaults to Model

      Parameters

      • registry: Registry

        The Storehouse registry containing registered managers

      • managerName: string
      • modelName: string

        The name of the model to retrieve

      Returns M

      The requested ModelStatic instance

      If the model is not found in the registry

      const User = getModel(registry, 'User');
      const users = await User.findAll();
    • Retrieves a Sequelize model from the registry.

      Type Parameters

      • TModelAttributes extends Record<string, unknown> = AnyJsonObject
      • TCreationAttributes extends Record<string, unknown> = AnyJsonObject

      Parameters

      • registry: Registry

        The Storehouse registry containing registered managers

      • modelName: string

        The name of the model to retrieve

      Returns ModelStatic<Model<TModelAttributes, TCreationAttributes>>

      The requested ModelStatic instance

      If the model is not found in the registry

      const User = getModel(registry, 'User');
      const users = await User.findAll();
    • Retrieves a Sequelize model from the registry.

      Type Parameters

      • TModelAttributes extends Record<string, unknown> = AnyJsonObject
      • TCreationAttributes extends Record<string, unknown> = AnyJsonObject

      Parameters

      • registry: Registry

        The Storehouse registry containing registered managers

      • managerName: string
      • modelName: string

        The name of the model to retrieve

      Returns ModelStatic<Model<TModelAttributes, TCreationAttributes>>

      The requested ModelStatic instance

      If the model is not found in the registry

      const User = getModel(registry, 'User');
      const users = await User.findAll();