Page Contents

Home > @loopback/sequelize > SequelizeCrudRepository > getTableName

SequelizeCrudRepository.getTableName() method

This function retrieves the table name associated with a given entity class. Different loopback connectors have different conventions for picking up table names, unless the name is specified in the decorator.

The function follows the following cases to determine the table name: - It checks if the name property is specified in the decorator and uses it. (this takes precedence over all other cases) - If the dialect of the dataSource is PostgreSQL, it uses the lowercased version of the model class name. - If the dialect is MySQL or any other dialect, it uses the default model class name.

Signature:

getTableName(entityClass?: typeof Entity & {
        prototype: T;
    }): string;

Parameters

Parameter Type Description
entityClass typeof Entity & { prototype: T; } (Optional) The entity class for which the table name is being retrieved.

Returns:

string

{string} - The table name associated with the entity class. Which is used when performing the query.