Home > @loopback/sequelize > SequelizeCrudRepository
SequelizeCrudRepository class
Sequelize implementation of CRUD repository to be used with default loopback entities and SequelizeDataSource for SQL Databases
Signature:
export declare class SequelizeCrudRepository<T extends Entity, ID, Relations extends object = {}> implements EntityCrudRepository<T, ID, Relations>
Implements: EntityCrudRepository<T, ID, Relations>
Constructors
| Constructor | Modifiers | Description |
|---|---|---|
|
Constructs a new instance of the |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
|
|
readonly [“postgresql”, “mysql”, “sqlite3”] |
Object keys used in models for set database specific settings. Example: In model property definition one can use postgresql dataType as float This array of keys is used while building model definition for sequelize. | |
|
|
(not declared) |
Default | |
|
|
Record<string, unknown> |
The alias registry for See: https://loopback.io/doc/en/lb4/Model.html#property-decorator | |
|
typeof Entity & { prototype: T; } | |||
|
|
Map<string, InclusionResolver<T, Entity>> | ||
|
number |
Length of the | ||
|
ModelStatic<Model<T>> |
Sequelize Model Instance created from the model definition received from the |
Methods
| Method | Modifiers | Description |
|---|---|---|
|
|
Get Sequelize | |
|
|
Build Sequelize compatible | |
|
|
Get Sequelize Order filter value from loopback style order value. It also supports passing associations in the order array to sort by nested models. Example: | |
|
|
Build Sequelize compatible where condition object | |
|
createBelongsToAccessorFor(relationName, targetRepositoryGetter) |
|
Function to create a belongs to accessor |
|
createHasManyRepositoryFactoryFor(relationName, targetRepositoryGetter) |
|
Function to create a constrained relation repository factory |
|
|
Function to create a constrained hasManyThrough relation repository factory | |
|
createHasOneRepositoryFactoryFor(relationName, targetRepositoryGetter) |
|
Function to create a constrained hasOne relation repository factory |
|
createReferencesManyAccessorFor(relationName, targetRepoGetter) |
|
Function to create a references many accessor |
|
|
Remove hidden properties specified in model from response body. (See: https://github.com/sourcefuse/loopback4-sequelize/issues/3) | |
|
Execute a SQL command. **WARNING:** In general, it is always better to perform database actions through repository methods. Directly executing SQL may lead to unexpected results, corrupted data, security vulnerabilities and other issues. | ||
|
| ||
|
Get Sequelize Model | ||
|
|
Get Sequelize Model Attributes | |
|
|
Get Sequelize Operator | |
|
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. | ||
|
includeReferencesIfRequested(parentEntities, parentEntityClass, inclusionFilters) |
|
Include related entities of referencesMany relation is NOT handled by |
|
|
Checks if the resolver of the inclusion relation is registered in the inclusionResolver of the current repository | |
|
Register an inclusion resolver for the related model name. | ||
|
Run CREATE TABLE query for the all sequelize models, Useful for quick testing | ||
|
Run CREATE TABLE query for the target sequelize model, Useful for quick testing | ||
|
| ||