Skip to content

feat: Pagination. Add Page class and req params mapper#101

Open
OlegMakarenko wants to merge 2 commits into
devfrom
pagination
Open

feat: Pagination. Add Page class and req params mapper#101
OlegMakarenko wants to merge 2 commits into
devfrom
pagination

Conversation

@OlegMakarenko

@OlegMakarenko OlegMakarenko commented Nov 9, 2021

Copy link
Copy Markdown
Contributor

Usage:

import { reqToPageParameters } from '@src/utils';
import { Page } from '@src/infrastructure/Page';

async (req: Request): Promise<ExamplePageDTO> => {
	return (
		await new Page<IExample, ExampleDTO>(
			reqToPageParameters(req, ['filter1']), // map query parameters to search criteria and filters
			ExampleMongooseModel, // mongoose.Model<IExample>
			(_) => _.map(ExampleService.convertToDTO), // map document to DTO
		).exec()
	).toObject();
},

@OlegMakarenko OlegMakarenko linked an issue Nov 9, 2021 that may be closed by this pull request
Comment thread src/utils.ts
return all;
}, []);

export const reqToPageParameters = (req: Request, filterKeys?: Array<string>): { [key: string]: unknown } => {

@AnthonyLaw AnthonyLaw Nov 12, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array<string> vs string[]

I think we have different styles for the Typescript type, should we unite the style?

@AnthonyLaw AnthonyLaw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good for me.
@fboucquez @yilmazbahadir has a better experience than me as they are working pagination for SDK and REST.

@Wayonb Wayonb force-pushed the dev branch 2 times, most recently from fc6c3a7 to e756bdc Compare December 18, 2024 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

task: add pagination

2 participants