diegohaz/querymen

Multiple filters same path custom schema

chemitaxis opened this issue · 8 comments

Hi, if you add this to the middleware:

query({
    after: {
      type: Date,
      paths: ['DateInvoice'],
      operator: '$gte'
    },
    before: {
      type: Date,
      paths: ['DateInvoice'],
      operator: '$lte'
    }
  }),

Just the last is working, the first (after) is ignored... Any ideas? Thanks

Hi @diegohaz Did you have time to check this? Thank you so much!!

Here you have a test failing the issue:

request(
        route(
          new querymen.Schema({
            before: {
              type: Date,
              operator: '$lte',
              paths: ['createdAt']
            },
            after: {
              type: Date,
              operator: '$gte',
              paths: ['createdAt']
            }
          })
        )
      )
        .get('/tests')
        .query({ after: '2016-04-22T10:00', before: '2016-04-23T09:00' })
        .expect(200)
        .end((err, res) => {
          if (err) throw err
          t.equal(res.body.length, 1, 'should respond with 1 item')
          t.equal(
            res.body[0].title,
            'nice!',
            'should respond with item after date and before date'
          )
        })

Could you start a PR with that test so we can try to pass it?

of course ;)

Done ;) Thanks @diegohaz

Hi @diegohaz did you have time to check my PR? Thanks!

I'm not able to do that right now. Will check that as soon as possible.

Fixed in #44