title: MongoDB Java Driver: How to use $cond operator?
body: <p>I've written the following MongoDB update query:</p>
  <pre><code>db.getCollection(&quot;product&quot;).update(
    {},
    [
      {
        $set: {
          availability: {
            $cond: [
              {
                $eq: [&quot;$availability&quot;, true],
              },
              &quot;Yes&quot;,
              &quot;No&quot;,
            ],
          },
        },
      }
    ]
  );
  </code></pre>
  <p>that updates all documents in <code>product</code> collection: set a new value for <code>availability</code> property based on its current value.</p>
  <p>And I am trying to rewrite the query above for MongoDB Java driver:</p>
  <pre><code>db.getCollection(&quot;product&quot;)
       .updateMany(new BsonDocument(), Updates.set(&quot;available&quot;, &quot;YES&quot;));
  </code></pre>
  <p>but I am stuck with <code>$cond</code> operator, I don't know how to translate <code>$cond</code> operator from MongoDB query to Java driver.</p>
  <p>Could you please suggest possible options?</p>