Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserCompany(db.Document, TransitionalDatabaseMixin):
- '''
- A company that our users belong to. Not to be confused with
- companies that are offering positions.
- '''
- # Classic getter with no filtering.
- @classmethod
- def get_by_ats_id(cls, ats_id):
- return cls.objects(ats_id=ats_id).first()
- # Provide a getter that supports filtering.
- # The naming convention implies the getter filters.
- # The downside here is that we need to name a filtered getter for every
- # getter we define.
- @classmethod
- def get_by_ats_id_with_limits(cls, ats_id, *limits):
- return cls.objects(ats_id=ats_id).only(*limits)
- # An alternate solution is to keep our default named getter and have an
- # optional list of filters that maybe be defined. The caller may now use
- # the same getter when they want all fields or just a subset.
- @classmethod
- def get_by_ats_id(cls, ats_id, limits=[]):
- return cls.objects(ats_id=ats_id).only(*limits)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement