Page Contents

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
(constructor)(entityClass, dataSource)   Constructs a new instance of the SequelizeCrudRepository class

Properties

Property Modifiers Type Description
dataSource   SequelizeDataSource  
DB_SPECIFIC_SETTINGS_KEYS readonly readonly [“postgresql”, “mysql”, “sqlite3”] <p>Object keys used in models for set database specific settings. Example: In model property definition one can use postgresql dataType as float { type: 'number', postgresql: { dataType: 'float', precision: 20, scale: 4, }, }</p><p>This array of keys is used while building model definition for sequelize.</p>
DEFAULT_ORDER_STYLE readonly (not declared) Default order filter style if only column name is specified
entityClass   typeof Entity & { prototype: T; }  
inclusionResolvers readonly Map<string, InclusionResolver<T, Entity>>  
sequelizeModel   ModelStatic<Model<T>> Sequelize Model Instance created from the model definition received from the entityClass

Methods

Method Modifiers Description
beginTransaction(options)    
buildSequelizeAttributeFilter(fields) protected Get Sequelize attributes filter value from fields of loopback.
buildSequelizeIncludeFilter(inclusionFilters, sourceModel) protected Build Sequelize compatible include filter
buildSequelizeOrder(order) protected Get Sequelize Order filter value from loopback style order value
buildSequelizeWhere(where) protected Build Sequelize compatible where condition object
count(where, options)    
create(entity, options)    
createAll(entities, options)    
createBelongsToAccessorFor(relationName, targetRepositoryGetter) protected Function to create a belongs to accessor
createHasManyRepositoryFactoryFor(relationName, targetRepositoryGetter) protected Function to create a constrained relation repository factory
createHasManyThroughRepositoryFactoryFor(relationName, targetRepositoryGetter, throughRepositoryGetter) protected Function to create a constrained hasManyThrough relation repository factory
createHasOneRepositoryFactoryFor(relationName, targetRepositoryGetter) protected Function to create a constrained hasOne relation repository factory
createReferencesManyAccessorFor(relationName, targetRepoGetter) protected Function to create a references many accessor
delete(entity, options)    
deleteAll(where, options)    
deleteById(id, options)    
excludeHiddenProps(entity) protected Remove hidden properties specified in model from response body. (See: https://github.com/sourcefuse/loopback4-sequelize/issues/3)
execute(_args)    
exists(id, _options)    
find(filter, options)    
findById(id, filter, options)    
findOne(filter, options)    
getSequelizeModel(entityClass)   Get Sequelize Model
getSequelizeModelAttributes(definition) protected Get Sequelize Model Attributes
getSequelizeOperator(key) protected Get Sequelize Operator
includeReferencesIfRequested(parentEntities, parentEntityClass, inclusionFilters) protected <p>Include related entities of @referencesMany relation</p><p>referencesMany relation is NOT handled by sequelizeModel.findAll as it doesn’t have any direct alternative to it, so to include relation data of referencesMany, we’re manually fetching related data requested</p>
registerInclusionResolver(relationName, resolver)   Register an inclusion resolver for the related model name.
replaceById(id, data, options)    
save(entity, options)    
syncLoadedSequelizeModels(options)   Run CREATE TABLE query for the all sequelize models, Useful for quick testing
syncSequelizeModel(options)   Run CREATE TABLE query for the target sequelize model, Useful for quick testing
toEntities(models) protected  
update(entity, options)    
updateAll(data, where, options)    
updateById(id, data, options)