-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(service-provider-core): explicitly define cursor types in servi…
…ce-provider-core (#2008) Instead of directly using driver types, only define the types required for the Shell API, and define them separately from the driver. This addresses part of MONGOSH-915 and is likely to help pave the way for things like MONGOSH-1285.
- Loading branch information
Showing
10 changed files
with
114 additions
and
27 deletions.
There are no files selected for viewing
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,69 @@ | ||
import type { | ||
CollationOptions, | ||
CountOptions, | ||
CursorFlag, | ||
Document, | ||
ExplainVerbosityLike, | ||
ReadConcernLike, | ||
ReadPreferenceLike, | ||
ResumeToken, | ||
} from './all-transport-types'; | ||
|
||
interface ServiceProviderBaseCursor<TSchema = Document> { | ||
close(): Promise<void>; | ||
hasNext(): Promise<boolean>; | ||
next(): Promise<TSchema | null>; | ||
tryNext(): Promise<TSchema | null>; | ||
readonly closed: boolean; | ||
[Symbol.asyncIterator](): AsyncGenerator<TSchema, void, void>; | ||
} | ||
|
||
export interface ServiceProviderAbstractCursor<TSchema = Document> | ||
extends ServiceProviderBaseCursor<TSchema> { | ||
batchSize(number: number): void; | ||
maxTimeMS(value: number): void; | ||
bufferedCount(): number; | ||
readBufferedDocuments(number?: number): TSchema[]; | ||
toArray(): Promise<TSchema[]>; | ||
} | ||
|
||
export interface ServiceProviderAggregationOrFindCursor<TSchema = Document> | ||
extends ServiceProviderAbstractCursor<TSchema> { | ||
project($project: Document): void; | ||
skip($skip: number): void; | ||
sort($sort: Document): void; | ||
explain(verbosity?: ExplainVerbosityLike): Promise<Document>; | ||
addCursorFlag(flag: CursorFlag, value: boolean): void; | ||
withReadPreference(readPreference: ReadPreferenceLike): this; | ||
withReadConcern(readConcern: ReadConcernLike): this; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ServiceProviderRunCommandCursor<TSchema = Document> | ||
extends ServiceProviderAbstractCursor<TSchema> {} | ||
|
||
export interface ServiceProviderFindCursor<TSchema = Document> | ||
extends ServiceProviderAggregationOrFindCursor<TSchema> { | ||
allowDiskUse(allow?: boolean): void; | ||
collation(value: CollationOptions): void; | ||
comment(value: string): void; | ||
maxAwaitTimeMS(value: number): void; | ||
count(options?: CountOptions): Promise<number>; | ||
hint(hint: string | Document): void; | ||
max(max: Document): void; | ||
min(min: Document): void; | ||
limit(value: number): void; | ||
skip(value: number): void; | ||
returnKey(value: boolean): void; | ||
showRecordId(value: boolean): void; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ServiceProviderAggregationCursor<TSchema = Document> | ||
extends ServiceProviderAggregationOrFindCursor<TSchema> {} | ||
|
||
export interface ServiceProviderChangeStream<TSchema = Document> | ||
extends ServiceProviderBaseCursor<TSchema> { | ||
next(): Promise<TSchema>; | ||
readonly resumeToken: ResumeToken; | ||
} |
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
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