Handling missing fields when using Python lamda's
<p>I have this rethinkDB query which basically returns the documents which "basicConstraints" fields that start with "CA:FA".</p>

<p>However in some of my documents the "basicConstraints" field does not exist. </p>

<pre><code>q = r.db('scanafi').table(active_table) \
.concat_map(lambda doc: doc["certificates"]\
.concat_map(lambda x: x["parsed_certificate"]["X509 extensions"])\
    .filter(lambda x: x["basicConstraints"]
.match("^CA:FA"))) \
.run()
</code></pre>

<p>How can I also include all of the documents which contain this missing field in my query?</p>

<p>You can write <code>x.has_fields('basicConstraints').not().or_(x['basicConstraints'].match("^CA:FA"))</code>.</p>

python lambda rethinkdb rethinkdb-python