Skip to content

Commit

Permalink
fix(base_model): execute the query in findManyBy
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainLanz committed Mar 12, 2024
1 parent ea41f57 commit deb0052
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/orm/base_model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,14 +734,16 @@ class BaseModelImpl implements LucidRow {
options?: ModelAdapterOptions
) {
if (typeof key === 'object') {
return this.query(value as ModelAdapterOptions).where(key)
return this.query(value as ModelAdapterOptions)
.where(key)
.exec()
}

if (value === undefined) {
throw new Exception('"findManyBy" expects a value. Received undefined')
}

return this.query(options).where(key, value)
return this.query(options).where(key, value).exec()
}

/**
Expand Down Expand Up @@ -1982,8 +1984,8 @@ class BaseModelImpl implements LucidRow {
result[relation.serializeAs] = Array.isArray(value)
? value.map((one) => one.serialize(relationOptions))
: value === null
? null
: value.serialize(relationOptions)
? null

Check failure on line 1987 in src/orm/base_model/index.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `··`

Check failure on line 1987 in src/orm/base_model/index.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
: value.serialize(relationOptions)

Check failure on line 1988 in src/orm/base_model/index.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `··`

Check failure on line 1988 in src/orm/base_model/index.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `··`

return result
}, {})
Expand Down

0 comments on commit deb0052

Please sign in to comment.