You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking into a way to search for all documents that do not have a specific key set. Is there a way to do a search like Query().f1.exists() == False or not Query().f1.exists()? How can I find all documents that do not have a specific key?
A solution I found is to write my own not_exist function, but by looking at the code, all query functions call self._generate_test which I can't call in this case because _generate_test literally returns False if there is a KeyError exception, which renders it useless to check for the exact opposite 😆
defnot_exists(self) ->QueryInstance:
""" Test for a dict where a provided key not exists. >>> Query().f1.not_exists() """deftest(value):
forpartinself._path:
ifpartinvalue.keys():
returnFalsereturnTruereturnQueryInstance(
lambdavalue: test(value),
(('not_exists', self._path) ifself.is_cacheable() elseNone)
)
The text was updated successfully, but these errors were encountered:
I'm looking into a way to search for all documents that do not have a specific key set. Is there a way to do a search like
Query().f1.exists() == False
ornot Query().f1.exists()
? How can I find all documents that do not have a specific key?A solution I found is to write my own
not_exist
function, but by looking at the code, all query functions callself._generate_test
which I can't call in this case because_generate_test
literallyreturns False
if there is aKeyError
exception, which renders it useless to check for the exact opposite 😆The text was updated successfully, but these errors were encountered: