SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top