code: def _filter(cls, query, state=MembershipState.ACTIVE, eager=None):
          
          query = query.filter_by(state=state)
  
          eager = eager or []
          for field in eager:
              query = query.options(joinedload(field))
  
          return query
docs: Filter a query result.