Skip to content

Commit 2c2c534

Browse files
authored
Merge pull request #104 from richmolj/master
Fix WhereClause type
2 parents 485d883 + 0a1d7b9 commit 2c2c534

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/scope.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type SortDir = "asc" | "desc"
3131
export type SortScope = Record<string, SortDir>
3232
export type FieldScope = Record<string, string[]>
3333
export type FieldArg = FieldScope | string[]
34-
export type WhereClause = Record<string, string | number | boolean>
34+
export type WhereClause = Record<string, string | number | boolean | string[] | number[]>
3535
export type StatsScope = Record<string, string | string[]>
3636
export type IncludeScope = string | IncludeArgHash | (string | IncludeArgHash)[]
3737

test/integration/finders.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,23 @@ describe("Model finders", () => {
272272
expect(data[0]).to.have.property("id", "2")
273273
})
274274

275+
describe("when value is an array", () => {
276+
beforeEach(() => {
277+
fetchMock.reset()
278+
fetchMock.get(
279+
"http://example.com/api/v1/people?filter[id]=1,2,3",
280+
{
281+
data: [{ id: "2", type: "people" }]
282+
}
283+
)
284+
})
285+
286+
it('converts to comma-delimited string', async () => {
287+
const { data } = await Person.where({ id: [1, 2, 3] }).all()
288+
expect(data.length).to.eq(1)
289+
})
290+
})
291+
275292
describe("when value is false", () => {
276293
beforeEach(() => {
277294
fetchMock.reset()

0 commit comments

Comments
 (0)