@storehouse/redis-om - v1.0.0
    Preparing search index...

    Function getModel

    • Retrieves a Redis-OM Repository (model) from the registry.

      This function has two overload signatures:

      1. When called with 2 arguments, retrieves the model using the second argument as the model name from the default manager
      2. When called with 3 arguments, retrieves the model from a specific manager

      Type Parameters

      • T extends Record<string, any> = Record<string, any>

        The entity type that defines the structure of data stored in the repository. Defaults to Record<string, any>

      Parameters

      • registry: Registry

        The Storehouse registry containing registered managers and models

      • modelName: string

        When used with 2 arguments, this is the name of the model to retrieve

      Returns Repository<T & EntityData & EntityInternal>

      The requested Redis-OM Repository

      If the model is not found in the registry

      // Get model from default manager with typed entity
      interface User {
      name: string;
      email: string;
      age: number;
      }

      const userRepository = getModel<User>(registry, 'User');
      const users = await userRepository.search().return.all();
      // users will be typed as Array<User & Entity>
    • Retrieves a Redis-OM Repository (model) from a specific manager in the registry.

      Type Parameters

      • T extends Record<string, any> = Record<string, any>

        The entity type that defines the structure of data stored in the repository. Defaults to Record<string, any>

      Parameters

      • registry: Registry

        The Storehouse registry containing registered managers and models

      • managerName: string

        The name of the manager containing the model

      • modelName: string

        The name of the specific model to retrieve

      Returns Repository<T & EntityData & EntityInternal>

      The requested Redis-OM Repository typed with the entity structure

      If the model is not found in the registry

      // Get model from specific manager with typed entity
      interface Product {
      title: string;
      price: number;
      inStock: boolean;
      }

      const productRepository = getModel<Product>(registry, 'redis-manager', 'Product');
      const products = await productRepository.search().return.all();
      // products will be typed as Array<Product & Entity>