forked from Azure/azure-sdk-for-js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for LIMIT and OFFSET in queries (Azure#306)
- Loading branch information
1 parent
47fcaa4
commit 8ad3d5c
Showing
20 changed files
with
262 additions
and
357 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
src/queryExecutionContext/EndpointComponent/IEndpointComponent.ts
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Response } from "../../request"; | ||
import { ExecutionContext } from "../ExecutionContext"; | ||
import { getInitialHeader } from "../headerUtils"; | ||
|
||
/** @hidden */ | ||
export class OffsetLimitEndpointComponent implements ExecutionContext { | ||
constructor(private executionContext: ExecutionContext, private offset: number, private limit: number) {} | ||
|
||
public async nextItem(): Promise<Response<any>> { | ||
if (this.offset > 0) { | ||
// Grab next item but ignore the result. We only need the headers | ||
const { headers } = await this.executionContext.nextItem(); | ||
this.offset--; | ||
return { result: undefined, headers }; | ||
} | ||
if (this.limit > 0) { | ||
const response = await this.executionContext.nextItem(); | ||
this.limit--; | ||
return response; | ||
} | ||
// If both limit and offset are 0, return nothing | ||
return { result: undefined, headers: getInitialHeader() }; | ||
} | ||
|
||
public async current(): Promise<Response<any>> { | ||
if (this.offset > 0) { | ||
const current = await this.executionContext.current(); | ||
return { result: undefined, headers: current.headers }; | ||
} | ||
return this.executionContext.current(); | ||
} | ||
|
||
public hasMoreResults() { | ||
return (this.offset > 0 || this.limit > 0) && this.executionContext.hasMoreResults(); | ||
} | ||
} |
39 changes: 13 additions & 26 deletions
39
src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 0 additions & 62 deletions
62
src/queryExecutionContext/EndpointComponent/TopEndpointComponent.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ueryExecutionContext/IExecutionContext.ts → ...queryExecutionContext/ExecutionContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.