Skip to content

Commit 68077e9

Browse files
committed
fix: return consistent type
1 parent 8bd2a47 commit 68077e9

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/cmap/wire_protocol/responses.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ function throwUnsupportedError() {
126126

127127
/** @internal */
128128
export class CursorResponse extends MongoDBResponse {
129+
static emptyGetMore = new CursorResponse(
130+
Buffer.from(
131+
'NgAAABBvawABAAAAA2N1cnNvcgAhAAAAEmlkAAAAAAAAAAAABG5leHRCYXRjaAAFAAAAAAAA',
132+
'base64'
133+
)
134+
);
135+
136+
static override is(value: unknown): value is CursorResponse {
137+
return value instanceof CursorResponse;
138+
}
139+
129140
public id: Long | null = null;
130141
public ns: MongoDBNamespace | null = null;
131142
public documents: any | null = null;
@@ -183,8 +194,4 @@ export class CursorResponse extends MongoDBResponse {
183194
push: { value: throwUnsupportedError }
184195
});
185196
}
186-
187-
static override is(value: unknown): value is CursorResponse {
188-
return value instanceof CursorResponse;
189-
}
190197
}

src/cursor/find_cursor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
110110
// instead, if we determine there are no more documents to request from the server, we preemptively
111111
// close the cursor
112112
}
113-
return { cursor: { id: Long.ZERO, nextBatch: [] } };
113+
return CursorResponse.emptyGetMore;
114114
}
115115
}
116116

0 commit comments

Comments
 (0)