title: Mongodb using dynamic fields with $not
body: <p>I programming in react, mongodb, nodejs and expressjs. I have a problem that I cannot solve. I would like to use dynamic fields from $not on the server. For example, the server gets the column name from the front and it is supposed to return the number of documents where the text is different from an empty string, i.e. <code>''</code>. I've tried to do something like this(code below), but it doesn't help.</p>
  <pre><code>const query = {};
  query[type] = { $not: '' };
  User.countDocuments(query, (err, data) =&gt; {
      if (err) return res.json({ success: false, error: err });
      return res.json({ success: true, data: data });
  });
  </code></pre>