mswjs / data

Data modeling and relation library for testing JavaScript applications.

Home Page:https://npm.im/@mswjs/data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for `in` and `notIn` filters for NumberQuery

ruisaraiva19 opened this issue · comments

Right now, we can't filter entries within an array of numbers.

We can only do it in String properties currently via either in or notIn.

const db = factory({
  book: {
    id: primaryKey(String),
    title: String,
    rating: Number,
  }
})

const books = db.book.findMany({
  where: {
    title: {
      in: ['foo', 'bar'], // this is fine
    },
    rating: {
      in: [3, 4, 5], // 'in' does not exist in type 'Partial<NumberQuery>'
    },
  },
})

Adding the same filters for Number properties would be great.

#150 has the work for this issue.

Hey, @ruisaraiva19. Thank you for suggesting and working on this!
I've reviewed the pull request and had only one minor comment. Looking forward to releasing this!

Hey @kettanaito. I'm glad I can help make this tool better for everyone.
I replied to your comments. Let me know if there is anything else needed and also look forward to the release!