Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @staticmethod
- def find(collection, query):
- return Database.DATABASE[collection].find(query)
- @classmethod
- def all(cls):
- return [cls(**elem) for elem in Database.find(ItemConstants.COLLECTION, {})]
- @classmethod
- def get_by_parameters(cls, name, category, url, size):
- return [cls(**elem) for elem in Database.find(ItemConstants.COLLECTION,
- {"name": name, "category": category, "url": url,
- "size": size}).sort('time', pymongo.DESCENDING).limit(1)][0]
- @staticmethod
- def find_min(collection, query, column):
- Database.DATABASE[collection].find(query).sort({column: pymongo.ASCENDING}).limit(1)
- @classmethod
- def get_by_parameters(cls, name, category, url, size):
- return cls(**Database.find_min(ItemConstants.COLLECTION,
- {"name": name, "category": category, "url": url,
- "size": size}, 'time'))
Add Comment
Please, Sign In to add comment