New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

querying null values #894

Closed
moayadnajd opened this Issue Jun 25, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@moayadnajd

moayadnajd commented Jun 25, 2018

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

@bertho-zero

This comment has been minimized.

Collaborator

bertho-zero commented Jun 25, 2018

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

@eddyystop

This comment has been minimized.

Member

eddyystop commented Jun 25, 2018

@daffl

This comment has been minimized.

Member

daffl commented Jun 25, 2018

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;
    }
  }
});

@daffl daffl closed this Jun 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment