from pymongo import MongoClient
# Configure MongoDB connection
client = MongoClient('mongodb://localhost:27017/')
db = client['twitter_database']
collection = db['tweets']
# Find the last tweet in the collection
last_tweet = collection.find_one({}, sort=[('$natural', -1)])
# Print the last tweet
print(last_tweet)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter