Simplify lookup cursor logic for ExternalAccountKeys
This commit is contained in:
parent
5fe9909174
commit
11a7f01177
1 changed files with 9 additions and 7 deletions
|
@ -282,13 +282,15 @@ func (db *DB) GetExternalAccountKeys(ctx context.Context, provisionerName, curso
|
||||||
if dbeak.Provisioner != provisionerName {
|
if dbeak.Provisioner != provisionerName {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// skip the IDs not matching the cursor to look for in the sorted list.
|
// look for the entry pointed to by the cursor (the next item to return) and start selecting items after finding it
|
||||||
if cursor != "" && !foundCursorKey && cursor != dbeak.ID {
|
if cursor != "" && !foundCursorKey {
|
||||||
|
if cursor == dbeak.ID {
|
||||||
|
// from here on, items should be selected for the result.
|
||||||
|
foundCursorKey = true
|
||||||
|
} else {
|
||||||
|
// skip the IDs not matching the cursor to look for.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// look for the entry pointed to by the cursor (the next item to return), to start selecting items
|
|
||||||
if cursor != "" && !foundCursorKey && cursor == dbeak.ID {
|
|
||||||
foundCursorKey = true
|
|
||||||
}
|
}
|
||||||
// return if the limit of items was found in the previous iteration; the next cursor is set to the next item to return
|
// return if the limit of items was found in the previous iteration; the next cursor is set to the next item to return
|
||||||
if len(keys) == limit {
|
if len(keys) == limit {
|
||||||
|
|
Loading…
Add table
Reference in a new issue