def method(class, doc): # read and fetch data from coll1 and get required fields
id = doc['id']
type = doc['type']
startdate = doc['startDate']
endDate = doc['endDate'])
match = class.mongo_db['coll2'] # match fields in coll1 and coll2 and fetch data from coll2
tar_value = sag.find({'id': id, 'type': type,'startDate':{'$lte': startdate},'endDate':{'$gte': endDate}})
target = []
for tar_value1 in tar_value:
target.append(tar_value1)
if len(target) == 1:
---------------
----------
----
--
else:
skip
i need to match data from both collections and fetch required data, if two documents got fetched from coll2 then we need to skip else proceed am sucessful in this with out having an issue if coll2 has proper 'endDate' to match, but in some senarios the the 'endDate' would be 00 then i need to consider it has 20500202(IF end data was 00) how can i do this in above mongo find querry,am unable to achive this if 'endDate' is 00
for ex- if enddate of coll1 is 20210303 and end date od coll2 is 00 then we should consider it as (20500202 > 20210303) not (00 > 20210303)
Aucun commentaire:
Enregistrer un commentaire