-
-
Notifications
You must be signed in to change notification settings - Fork 176
feat: add pagination to getAllBuckets #707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 15547360956Details
💛 - Coveralls |
@@ -28,9 +28,10 @@ const requestQuerySchema = { | |||
type: 'object', | |||
properties: { | |||
limit: { type: 'integer', minimum: 1, examples: [10] }, | |||
offset: { type: 'integer', minimum: 0, examples: [0] }, | |||
offset: { type: 'integer', minimum: 1, examples: [1] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think offset min being 0 is fine. It's "useless" but a lot of time there will be code that sets a counter to 0 and increments it by limit per iteration and we shouldn't error if they pass in 0.
Also, I just checked listObjects and that is the behavior there so that would be consistent.
@@ -288,15 +288,19 @@ export class StorageKnexDB implements Database { | |||
const data = await this.runQuery('ListBuckets', (knex) => { | |||
const query = knex.from<Bucket>('buckets').select(columns.split(',')) | |||
|
|||
if (options?.sortColumn) { | |||
if (options?.search !== undefined) { | |||
query.where('name', 'like', `${options.search}%`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should use ilike
and probably %${options.search}%
to search anywhere in the string without case sensitivity.
The current dashboard search behavior searches anywhere in the string, but is case sensitive. However, our object search uses ilike so I think we should stay consistent with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also safely do zz?.search?.length > 0
. This will resolve to false if search is undefined or an empty string. The like won't hurt anything if the string is empty, but it also doesn't add anything.
What kind of change does this PR introduce?
Feature to add pagination to the GET buckets endpoint by introducing optional query parameters
limit
,offset
,sortColumn
andsortOrder
What is the current behavior?
Currently, we do not allow pagination for GET buckets endpoint.
What is the new behavior?
Now we allow optional query parameters to be passed in to allow pagination.
Additional context