Skip to content

querying null values  #894

Closed
Closed

Description

@moayadnajd

Sorry if my question is stupid but i am new to feathers

I'am trying to get users where there phone number is null

GET /users?phone=null this is not working

so what is the best way to do this ?

Thanks

Activity

  1. bertho-zero commented on Jun 25, 2018

    @bertho-zero
    Contributor

    Query is always a string, so you have to coerce this (in a before hook for exemple).

  2. eddyystop commented on Jun 25, 2018

    @eddyystop
    Contributor
  3. daffl commented on Jun 25, 2018

    @daffl
    Member

    That's definitely the way to go. For reference here is how it could be done in a plain hook:

    app.service('myservice').hooks({
      before: {
        find(context) {
          const { params: { query = {} } } = context;
    
          if(query.phone === 'null') {
            query.phone = null;
          }
    
          context.params.query = query;
    
          return context;
        }
      }
    });
  4. lock commented on Feb 7, 2019

    @lock

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

  5. locked as resolved and limited conversation to collaborators on Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions