Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/operations/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ export class DeleteOperation extends CommandOperation<Document> {
: undefined;
}

const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0;
if (unacknowledgedWrite || maxWireVersion(server) < 5) {
if (this.statements.find((o: Document) => o.hint)) {
callback(new MongoCompatibilityError(`Servers < 3.4 do not support hint on delete`));
if (maxWireVersion(server) < 9) {
const hintPresent = this.statements.some(o => o.hint);
const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0;

if (hintPresent && unacknowledgedWrite) {
callback(
new MongoCompatibilityError(`Servers < 4.4 do not support hint on unacknowledged delete`)
);
return;
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/operations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ export class UpdateOperation extends CommandOperation<Document> {
return;
}

const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0;
if (unacknowledgedWrite || maxWireVersion(server) < 5) {
if (this.statements.find((o: Document) => o.hint)) {
callback(new MongoCompatibilityError(`Servers < 3.4 do not support hint on update`));
if (maxWireVersion(server) < 8) {
const hintPresent = this.statements.some(o => o.hint);
const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0;

if (hintPresent && unacknowledgedWrite) {
callback(
new MongoCompatibilityError(`Servers < 4.2 do not support hint on unacknowledged update`)
);
return;
}
}
Expand Down