diegohaz/querymen

[Question, Help needed] Remove Limit

andrewgamez opened this issue ยท 10 comments

Hello!
Is there any way to show more than 100 results? or remove the limit?
thx

Yes, try this:

querymen.middleware({
  page: {
    max: 1000
  }
})

To remove the limit, set it to Infinity

Hi @diegohaz where do I put that code? I'm using the default directory/file structure from your REST API generator.

@fsalaysay on each index.js for the generated api endpoint you'll find a query(), which is the querymen middleware

Hi @danmmx

Thanks for the help but I tried

router.get('/',
  query(),
  index)

and

router.get('/',
  query({}, { // using default schema
    page: {
      max: 1000
    }
  }),
  index)

but both still doesn't work and responds with just the default 30. I know you're supposed to pass options as the second argument, but yeah, still getting 30 items. Any help?

The example is the following @fsalaysay

querymen.middleware({
  page: {
    max: 1000
  }
})

which you are not applying on yours. You can see here the following:

import { middleware as query } from 'querymen'

that means querymen.middleware is renamed to query. So that means you need to do

query({
  page: {
    max: 1000
  }
})

instead of what you're doing (query() and query({}, { page: { max: 1000 }}))

Can I remove the limit from the Schema?
I have this:
var schema = new querymen.Schema({ sort: '-creationDate', search: { type: RegExp, paths: ['name', 'description'] } })

AND

querymen.middleware(schema)

But if I add page: {max: 1000}, it has an error

What's the error @DiegoPerea ?
Have you tried Infinity as max limit?

The example is the following @fsalaysay

querymen.middleware({
  page: {
    max: 1000
  }
})

which you are not applying on yours. You can see here the following:

import { middleware as query } from 'querymen'

that means querymen.middleware is renamed to query. So that means you need to do

query({
  page: {
    max: 1000
  }
})

instead of what you're doing (query() and query({}, { page: { max: 1000 }}))

Hi @danmmx
It's still not work for me. please help

Can you share your code or something we can work from @ImamCandra ?

This is not
query({ page: { max: 1000 } })
but
query({ limit: { max: 1000 } })

have a good day :)