Skip to content

Commit 57b36d6

Browse files
committed
refactor(sequelize): Update to specify the update and create types
1 parent 1fca931 commit 57b36d6

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

packages/query-sequelize/src/services/sequelize-query.service.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { RelationQueryService } from './relation-query.service';
3737
*/
3838
export class SequelizeQueryService<Entity extends Model<Entity>>
3939
extends RelationQueryService<Entity>
40-
implements QueryService<Entity> {
40+
implements QueryService<Entity, DeepPartial<Entity>, DeepPartial<Entity>> {
4141
readonly filterQueryBuilder: FilterQueryBuilder<Entity>;
4242

4343
constructor(readonly model: ModelCtor<Entity>) {
@@ -123,7 +123,7 @@ export class SequelizeQueryService<Entity extends Model<Entity>>
123123
* ```
124124
* @param record - The entity to create.
125125
*/
126-
async createOne<C extends DeepPartial<Entity>>(record: C): Promise<Entity> {
126+
async createOne(record: DeepPartial<Entity>): Promise<Entity> {
127127
await this.ensureEntityDoesNotExist(record);
128128
return this.model.create<Entity>(this.getChangedValues(record));
129129
}
@@ -140,7 +140,7 @@ export class SequelizeQueryService<Entity extends Model<Entity>>
140140
* ```
141141
* @param records - The entities to create.
142142
*/
143-
async createMany<C extends DeepPartial<Entity>>(records: C[]): Promise<Entity[]> {
143+
async createMany(records: DeepPartial<Entity>[]): Promise<Entity[]> {
144144
await Promise.all(records.map((r) => this.ensureEntityDoesNotExist(r)));
145145
return this.model.bulkCreate<Entity>(records.map((r) => this.getChangedValues(r)));
146146
}
@@ -156,11 +156,7 @@ export class SequelizeQueryService<Entity extends Model<Entity>>
156156
* @param update - A `Partial` of the entity with fields to update.
157157
* @param opts - Additional options.
158158
*/
159-
async updateOne<U extends DeepPartial<Entity>>(
160-
id: number | string,
161-
update: U,
162-
opts?: UpdateOneOptions<Entity>,
163-
): Promise<Entity> {
159+
async updateOne(id: number | string, update: DeepPartial<Entity>, opts?: UpdateOneOptions<Entity>): Promise<Entity> {
164160
this.ensureIdIsNotPresent(update);
165161
const entity = await this.getById(id, opts);
166162
return entity.update(this.getChangedValues(update));
@@ -179,7 +175,7 @@ export class SequelizeQueryService<Entity extends Model<Entity>>
179175
* @param update - A `Partial` of entity with the fields to update
180176
* @param filter - A Filter used to find the records to update
181177
*/
182-
async updateMany<U extends DeepPartial<Entity>>(update: U, filter: Filter<Entity>): Promise<UpdateManyResponse> {
178+
async updateMany(update: DeepPartial<Entity>, filter: Filter<Entity>): Promise<UpdateManyResponse> {
183179
this.ensureIdIsNotPresent(update);
184180
const [count] = await this.model.update(
185181
this.getChangedValues(update),

0 commit comments

Comments
 (0)