Hello,
I am trying to query my Data Table for rows where the “email_confirmed” column has “True” value and the “apartment” column has “n” value. My goal is to ensure newly registered users don’t try to register the same apartment that another user has already registered, so long as the account is confirmed by email.
I could do this easily enough while I was only checking for dupe “apartments” in a single column, but now I am forced to work with the SearchIterator object because I am doing a more complex query, and the result is not a simple list. My code is below (I commented out the Query operators part):
@tables.in_transaction
def is_apartment_dupe(apartment):
#y = app_tables.users.search(q.all_of(confirmed_email=True, apartment=apartment))
#for x in y:
# print(x)
all_apts = [r['apartment'] for r in app_tables.users.search()]
if str(apartment) not in all_apts:
print("no dupe apartment found")
return None
else:
return "duplicate apartment found"
How can I check the returned SearchIterator for values? When I tried printing (y), I don’t get an output like a dict, but rather an object, but I couldn’t find documentation about its functions.