{'_id': ObjectId('61e62ed9f373e66efa5b9694'),
'year': '2021',
'category': 'chemistry',
'laureates': [{'id': '1002',
'firstname': 'Benjamin',
'surname': 'List',
'motivation': '"for the development of asymmetric organocatalysis"',
'share': '2'},
{'id': '1003',
'firstname': 'David',
'surname': 'MacMillan',
'motivation': '"for the development of asymmetric organocatalysis"',
'share': '2'}]}
{'_id': ObjectId('61e62ed9f373e66efa5b9926'),
'id': '1',
'firstname': 'Wilhelm Conrad',
'surname': 'Röntgen',
'born': '1845-03-27',
'died': '1923-02-10',
'bornCountry': 'Prussia (now Germany)',
'bornCountryCode': 'DE',
'bornCity': 'Lennep (now Remscheid)',
'diedCountry': 'Germany',
'diedCountryCode': 'DE',
'diedCity': 'Munich',
'gender': 'male',
'prizes': [{'year': '1901',
'category': 'physics',
'share': '1',
'motivation': '"in recognition of the extraordinary services he has rendered by the discovery of the remarkable rays subsequently named after him"',
'affiliations': [{'name': 'Munich University',
'city': 'Munich',
'country': 'Germany'}]}]}
{'Barbados',
'East Germany (now Germany)',
'Gabon',
'Greece',
'Israel',
'Jamaica',
'Northern Rhodesia (now Zambia)',
'Puerto Rico',
'Singapore',
'Tunisia',
'Yugoslavia (now Serbia)'}
['Australia', 'Denmark', 'USA', 'United Kingdom']
{'_id': ObjectId('61e62ed9f373e66efa5b9927'),
'id': '2',
'firstname': 'Hendrik A.',
'surname': 'Lorentz',
'born': '1853-07-18',
'died': '1928-02-04',
'bornCountry': 'the Netherlands',
'bornCountryCode': 'NL',
'bornCity': 'Arnhem',
'diedCountry': 'the Netherlands',
'diedCountryCode': 'NL',
'gender': 'male',
'prizes': [{'year': '1902',
'category': 'physics',
'share': '2',
'motivation': '"in recognition of the extraordinary service they rendered by their researches into the influence of magnetism upon radiation phenomena"',
'affiliations': [{'name': 'Leiden University',
'city': 'Leiden',
'country': 'the Netherlands'}]}]}
# Save a filter for laureates matching 3 criteria
# 1) won a prize excluding physics and chemistry and medicine
# 2) won a unshared prize
# 3) awared after or equals to 1945
unshared = {
"prizes": {"$elemMatch": {
"category": {"$nin": ["physics", "chemistry", "medicine"]},
"share": "1",
"year": {"$gte": "1945"},
}}}
# Save a filter for laureates matching 3 criteria
# 1) won a prize excluding physics and chemistry and medicine
# 2) won a shared prize
# 3) awared after or equals to 1945
shared = {
"prizes": {"$elemMatch": {
"category": {"$nin": ["physics", "chemistry", "medicine"]},
"share": {"$ne": "1"},
"year": {"$gte": "1945"},
}}}
# ratio of unsahred / shared
db.laureates.count_documents(unshared) / db.laureates.count_documents(shared)
from bson.regex import Regex
# number of laureates with a first name beginning with "G" and a surname beginning with "S"
db.laureates.count_documents({"firstname": {"$regex": "^G", "$options": "i"}, "surname":{"$regex":"^S", "$options": "i"}})
# 위와 같음
# db.laureates.count_documents({"firstname": Regex("^G", "i"), "surname": Regex("^S", "i")})
['Germany (now France)', 'Germany (now Poland)', 'Germany (now Russia)']
{'East Friesland (now Germany)', 'Prussia (now Germany)', 'Württemberg (now Germany)', 'Bavaria (now Germany)', 'Mecklenburg (now Germany)', 'Hesse-Kassel (now Germany)', 'Schleswig (now Germany)', 'West Germany (now Germany)'}
[('William B.', 'Shockley'), ('John', 'Bardeen'), ('Walter H.', 'Brattain')]