Skip to content

Commit

Permalink
fix(Query): findIn should resolve relations like it's counterpart `…
Browse files Browse the repository at this point in the history
…find`.
  • Loading branch information
cuebit committed Mar 6, 2020
1 parent f37c6f4 commit 11b0994
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/query/Query.ts
Expand Up @@ -267,7 +267,7 @@ export default class Query<T extends Model = Model> {
* Get the record of the given array of ids.
*/
findIn (idList: (number | string | (number | string)[])[]): Data.Collection<T> {
return idList.reduce<Data.Collection<T>>((collection, id) => {
const records = idList.reduce<Data.Collection<T>>((collection, id) => {
const indexId = Array.isArray(id) ? JSON.stringify(id) : id

const record = this.state.data[indexId]
Expand All @@ -280,6 +280,8 @@ export default class Query<T extends Model = Model> {

return collection
}, [])

return this.collect(records)
}

/**
Expand Down Expand Up @@ -343,7 +345,7 @@ export default class Query<T extends Model = Model> {
* Add a or where clause to the query.
*/
orWhere (field: any, value?: any): this {
// Cacncel id filter usage, since "or" needs full scan.
// Cancel id filter usage, since "or" needs full scan.
this.cancelIdFilter = true

this.wheres.push({ field, value, boolean: 'or' })
Expand Down Expand Up @@ -637,7 +639,7 @@ export default class Query<T extends Model = Model> {
}

/**
* Limit the given records by the lmilt and offset.
* Limit the given records by the limit and offset.
*/
filterLimit (records: Data.Collection<T>): Data.Collection<T> {
return Filter.limit<T>(this, records)
Expand Down

0 comments on commit 11b0994

Please sign in to comment.