You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
757 B

4 years ago
  1. # `whereIn()`
  2. The whereIn method filters the collection by a given key / value contained within the given array.
  3. ```js
  4. const collection = collect([
  5. { product: 'Desk', price: 200 },
  6. { product: 'Chair', price: 100 },
  7. { product: 'Bookcase', price: 150 },
  8. { product: 'Door', price: 100 },
  9. ]);
  10. const filtered = collection.whereIn('price', [100, 150]);
  11. filtered.all();
  12. // [
  13. // { product: 'Chair', price: 100 },
  14. // { product: 'Bookcase', price: 150 },
  15. // { product: 'Door', price: 100 },
  16. // ]
  17. ```
  18. > When working with nested objects `whereIn()` method allows dot notated keys. E.g. `whereIn('product.categories', ['office-supplies', 'furniture'])`
  19. [View source on GitHub](https://github.com/ecrmnn/collect.js/blob/master/src/methods/whereIn.js)