master
bill 1 year ago
parent a31f90ed1e
commit 8901a7d2e2

@ -25,10 +25,13 @@ def comparator(a, b):
return cmp
else: return 1
return 0
from bson import ObjectId
match (a, b):
case (dict(), dict()):
return itcmp([*a.keys(), *a.values()], [*b.keys(), *b.values()])
case (ObjectId(aa), ObjectId(bb)):
return cmp(aa, bb)
case (Iterable(), Iterable()):
return itcmp(a, b)
case _ if type(a) == type(b):

@ -30,7 +30,7 @@ sols = ['db.bills.find({sponsor_name:"Marco Rubio"}, {_id:0, title: 1, sponsor_n
foreignField: "sponsor_state",
as:"otherBills"} },
{ $unwind: "$otherBills" },
{ $project: {title: 1, sponsor_name: 1, sponsor_state: 1, otherbill_id: "$otherBills._id", otherbill_title: "$otherBills.title", otherbill_sponser_name: "$otherBills.sponsor_name", otherbill_sponsor_state: "$otherBills.sponsor_state"}},
{ $project: {title: 1, sponsor_name: 1, sponsor_state: 1, otherbill_id: "$otherBills._id", otherbill_title: "$otherBills.title", otherbill_sponsor_name: "$otherBills.sponsor_name", otherbill_sponsor_state: "$otherBills.sponsor_state"}},
{ $match: {$expr: {$lt: ["$_id", "$otherbill_id"]}}}
])''',
'''db.congress.aggregate([

Loading…
Cancel
Save