title: Sequelize how to get all data if there is no query string passed
body: <p>I'm pretty new to Sequelize.</p>
  <p>I'm trying to create a handler to get all playlists in my database.</p>
  <p><strong>This is what I want to do:</strong></p>
  <ul>
  <li>If there is a query string then it should return the result based on that query.</li>
  <li>If there is no query string passed then it should return all my playlists.</li>
  </ul>
  <p>This is my playlist model:</p>
  <pre><code>const Playlist = db.define(&quot;playlist&quot;, {
    id: {
      type: Sequelize.INTEGER,
      autoIncrement: true,
      primaryKey: true,
    },
    name: {
      type: Sequelize.STRING,
      unique: true,
    },
  });
  </code></pre>
  <p>Here is my handler:</p>
  <pre><code>exports.getPlaylists = async (req, res) =&gt; {
    try {
      const { name } = req.query;
      console.log(name); // this prints the name
      const result = await Playlist.findAll({
        where: {
          name:
            name === undefined ? {} : { $like: `%${name}%` },
        },
      });
      if (result) {
        res.status(200).send(result);
      } else {
        response.status(404).send(&quot;No Playlists found&quot;);
      }
    } catch (error) {
      res.status(500).send(`Internal server error: ${error}`);
    }
  };
  </code></pre>
  <p>This works well if I passed a name in the query. but If I didn't pass any query string. It returns an empty array.</p>
  <p><code>$like</code> is an alias for <code>Sequelize.Op.like</code></p>
  <p>What should I put instead of the empty object?</p>
  <p>I checked this question <a href="https://stackoverflow.com/questions/52901601/how-get-all-data-if-field-in-query-string-is-empty-node-and-sequelize-with-postg">How get all data if field in query string is empty Node and Sequelize with Postgres</a> but the proposed solutions didn't work with me</p>