mswjs / data

Data modeling and relation library for testing JavaScript applications.
https://npm.im/@mswjs/data
MIT License
829 stars 52 forks source link

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

Closed ruisaraiva19 closed 3 years ago

ruisaraiva19 commented 3 years ago

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.

ruisaraiva19 commented 3 years ago

150 has the work for this issue.

kettanaito commented 3 years ago

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!

ruisaraiva19 commented 3 years ago

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!