mongodb - Inserting in inside a function -
i newbie @ interacting mongo , trying make function using in
property:
def find_inthe(key,*values): rdo=col.find({key:{'$in':list(values)}}) in rdo: return print(find_inthe('hair_colour','white','brown','black'))
however problem finding is returning first of values
, find_one
.
if try same outside function:
rdo=col.find({'hair_colour':{'$in':['white','brown','black']}}) in rdo: print(a)
it return dictionaries of collection.
my desired output function returns dictionaries selected colour hairs
$in
not @ fault here. it's return a
in loop. why don't return whole thing?
def find_inthe(key,*values): rdo = col.find({key:{'$in':list(values)}}) return list(rdo)
Comments
Post a Comment