Guest User

Untitled

a guest
Jan 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. id title fruit
  2. 99 Avacados are the best! avacado
  3.  
  4. ...
  5.  
  6. const fruits = [
  7. 'avacado',
  8. 'banana',
  9. 'tomato',
  10. 'apple'
  11. ];
  12.  
  13. const whereOrLike = fruits.map(fruit => ({
  14. title: {
  15. [Op.like]: `%${fruit}%`
  16. }
  17. }));
  18.  
  19. const fruitData = await Fruit.findAll({
  20. where: {
  21. [Op.or]: whereOrLike
  22. },
  23. order: [['title', 'ASC']]
  24. });
Add Comment
Please, Sign In to add comment