@@ -68,6 +68,27 @@ import {isTruelyObject} from './utils';
6868const debug = debugFactory ( 'loopback:sequelize:repository' ) ;
6969const debugModelBuilder = debugFactory ( 'loopback:sequelize:modelbuilder' ) ;
7070
71+ interface InclusionWithRequired extends Inclusion {
72+ /**
73+ * Setting this option to true will result in an inner join query that
74+ * explicitly requires the specified condition for the child model.
75+ *
76+ * @see https://loopback.io/pages/en/lb4/readmes/loopback-next/extensions/sequelize/#inner-join
77+ */
78+ required ?: boolean ;
79+ }
80+
81+ type InclusionFilterWithRequired = string | InclusionWithRequired ;
82+
83+ interface FilterWithRequired < T extends object > extends Filter < T > {
84+ include ?: InclusionFilterWithRequired [ ] ;
85+ }
86+
87+ type FilterWithRequiredExcludingWhere < T extends object > = Omit <
88+ FilterExcludingWhere < T > ,
89+ 'where'
90+ > ;
91+
7192/**
7293 * Sequelize implementation of CRUD repository to be used with default loopback entities
7394 * and SequelizeDataSource for SQL Databases
@@ -231,7 +252,7 @@ export class SequelizeCrudRepository<
231252 }
232253
233254 async find (
234- filter ?: Filter < T > ,
255+ filter ?: FilterWithRequired < T > ,
235256 options ?: AnyObject ,
236257 ) : Promise < ( T & Relations ) [ ] > {
237258 const data = await this . sequelizeModel . findAll ( {
@@ -252,7 +273,7 @@ export class SequelizeCrudRepository<
252273 }
253274
254275 async findOne (
255- filter ?: Filter < T > ,
276+ filter ?: FilterWithRequired < T > ,
256277 options ?: AnyObject ,
257278 ) : Promise < ( T & Relations ) | null > {
258279 const data = await this . sequelizeModel . findOne ( {
@@ -279,7 +300,7 @@ export class SequelizeCrudRepository<
279300
280301 async findById (
281302 id : ID ,
282- filter ?: FilterExcludingWhere < T > ,
303+ filter ?: FilterWithRequiredExcludingWhere < T > ,
283304 options ?: AnyObject ,
284305 ) : Promise < T & Relations > {
285306 const data = await this . sequelizeModel . findByPk (
0 commit comments