benjamin658 / typeorm-cursor-pagination

Cursor-based pagination works with TypeORM Query Builder.
MIT License
184 stars 39 forks source link

Get SQL #32

Closed renehauck closed 3 years ago

renehauck commented 3 years ago

Would it also be possible to just get the generated SQL query instead of executing it directly? Background for this is that I would like to execute a pagination within a SubQuery.

Many thanks for this great tool.

benjamin658 commented 3 years ago

Thanks for your feedback.

The library has to execute the query to build the cursor, so it could be useless if it only returns the SQL query. However, if you really need the pagination query, fork the repo and check:

https://github.com/benjamin658/typeorm-cursor-pagination/blob/b6a377ef42676ad6d49e519619cb560fa3441432/src/Paginator.ts#L76

Just simply return this.appendPagingQuery(builder) to get the query.