Skip to content

Commit

Permalink
Use proper $select for results
Browse files Browse the repository at this point in the history
  • Loading branch information
DaddyWarbucks committed Nov 15, 2022
1 parent ec25764 commit ae974f2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,20 @@ export class SequelizeAdapter<
async $remove (id: NullableId, params: P = {} as P): Promise<T | T[]> {
const Model = this.ModelWithScope(params);

const itemOrItems = await this._getOrFind(id, params);
const findParams = { ...params };
if (params.$returning === false) {
findParams.query = {
...findParams.query,
$select: [this.id]
}
} else if (params.query?.$select) {
findParams.query = {
...findParams.query,
$select: [...params.query.$select, this.id]
}
}

const itemOrItems = await this._getOrFind(id, findParams);
const items = Array.isArray(itemOrItems) ? itemOrItems : [itemOrItems];
const ids: Id[] = items.map(item => item[this.id]);
const seqOptions = Object.assign(
Expand Down

0 comments on commit ae974f2

Please sign in to comment.