aravindnc / mongoose-paginate-v2

A custom pagination library for Mongoose with customizable labels.

Home Page:https://www.npmjs.com/package/mongoose-paginate-v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sorry, At present there are related performance test data analysis plugin, please

gtsigner opened this issue · comments

commented

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

At present there are related performance test data analysis plugin, please。
When I use paging plug-in data acquisition need each page 1 of article 1s time,if i use native mongoose to get total count and select list use 0.3s time,

@zhaojunlike Are you using the latest version v1.3.3?

commented

thx your reply ,i am using v1.3.2

old codes, 16ms

 @Get('')
  public async index(@Query() query, @Pager() pager: any, @Req() req: Request, @Res() res: Response) {
    const map: any = {};
    if (query.group && query.group !== '') {
      map.group = query.group;
    }
    if (query.username && query.username !== '') {
      map.username = { $regex: query.username };
    }
    const count = await this.model.countDocuments(map);
    const page = pager.parse(count);
    console.log(page);

    const list = await this.model.find(map).sort({ updateAt: -1 })
      .limit(page.limit)
      .skip(page.skip)
      .select('_id group username device.deviceType deviceType createAt updateAt status enable creator proxy')
      .populate('group');

    return res.status(HttpStatus.OK).json({
      message: 'success',
      data: {
        list: [],
      },
    });
  }

use paginate: 1532ms

 public async slow(@Query() query, @Pager() pager: any, @Req() req: Request, @Res() res: Response) {
    const map: any = {};
    if (query.group && query.group !== '') {
      map.group = query.group;
    }
    if (query.username && query.username !== '') {
      map.username = { $regex: query.username };
    }
    const count = await this.model.count(map);
    const page = pager.parser(count);
    console.log(page);
    const list = await this.model.paginate(map, {
      limit: pager.limit,
      offset: pager.skip,
      select: '_id group username device.deviceType deviceType createAt updateAt status enable creator proxy',
      populate: ['group'],
      sort: { updateAt: -1 },
    });

    return res.status(HttpStatus.OK).json({
      message: 'success',
      data: list,
    });
  }
commented

wow, v1.3.3 is very fast What's the difference between two version, please

commented

I also don't know why I isntall the old version,

wow, v1.3.3 is very fast What's the difference between two version, please

You can refer #48