title: How to implement query a resource by multi dimesions in flask-restful?
body: <p>As a new just learning flask, I have a few questions.</p>
  <pre><code>class Users(Resource):
      decorators = [...,]
  
      def get(self, user_id):
          &quot;&quot;&quot;
          GET /users : all uesers
          GET /users/1 : user where user_id = 1
          &quot;&quot;&quot;
          # do query user by user_id
  </code></pre>
  <p>In real business, thers is rarely queried users based on only one dimension, instead, most of the time, we need to query users based on multiple dimensions, such as</p>
  <ul>
  <li>query users by name</li>
  <li>query users by email address</li>
  <li>query users by name and create_time</li>
  <li>More ...</li>
  </ul>
  <p><strong>My Questions:</strong></p>
  <p><strong>Q1:</strong> as I know, there is only on get method in a flask-restful resource class, how to support so many query user functions in one get methon?
  many be like this,</p>
  <pre><code>def get(user_id=None, user_email=None, user_create_time=None, user_name=None):
      if user_id is None and user_email is None and user_create_time is None and user_name:
          query_user_by_name
      elif user_id is None and user_email and user_create_time is None and user_name is None:
          query_user_by_email
      ...
      
  </code></pre>
  <p>OH...HO..., It's smelly and long, really a disaster!</p>
  <p><strong>Q2:</strong> I also think that use different Resource, like:</p>
  <pre><code>    class UserNameResource(Resource):
          def get(user_name):
              query_user_by_name
  
      class UserNameAndCreateTimeResource(Resource):
          def get(user_name, create_time):
              query_user_by_name_and create_time
  
      ...
  </code></pre>
  <p>It's also long, ugly, and doesn't conform to restful naming rules, this is my second question.</p>
  <p><strong>Q3:</strong> Use post methon instead of get, because restful is not restricted to use POST method to query a resource. If this is Ok, so here comes my third question: how to distinguish 'create a resource' from 'query a resource' in a post method? Maybe with my limited understanding, like this?</p>
  <pre><code>class Users(Resource):
      def post(_method, **kwargs):
          if _method == 'QUERY':  # just a flag, could be others， as long as it's agreed in advance
              # query_resource, then query user by diffenent conditions
              
              if query_string in kwargs:
                  # query_sring is a dict, could used to ORM query, 
                  # so there is only one method for query users resouce, 
                  # there is no more other query_users_funcs like 
                  # query_user_by_name, query_user_id, 
                  # query_user_by_name_and_email ...
  
                 query_user_by_query_string
  
          if _method == 'CREATE':
              create_resource
  
  
  </code></pre>
  <p>I'm a newcomer to flask and restful. The above are my confusing, problems, and my own thoughts, which may be very immature.
  Welcome to discuss and guide me. Thank you very much.</p>