See last tweet code

PHOTO EMBED

Tue May 28 2024 21:39:14 GMT+0000 (Coordinated Universal Time)

Saved by @madgakantara

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)
content_copyCOPY