Skip to content

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

Open
OlegMakarenko wants to merge 2 commits intodevfrom
pagination
Open

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

Conversation

@OlegMakarenko
Copy link
Copy Markdown
Contributor

@OlegMakarenko OlegMakarenko commented Nov 9, 2021

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
return all;
}, []);

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

@AnthonyLaw AnthonyLaw Nov 12, 2021

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?

Copy link
Copy Markdown
Member

@AnthonyLaw AnthonyLaw left a comment

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