Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
fix(msg): support raw cursor results using OP_MSG
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Feb 12, 2019
1 parent 46b0a83 commit f91304b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/connection/msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ class BinMsg {
this.index = 4;
// Allow the return of raw documents instead of parsing
const raw = options.raw || false;
const documentsReturnedIn = options.documentsReturnedIn || null;
const promoteLongs =
typeof options.promoteLongs === 'boolean' ? options.promoteLongs : this.opts.promoteLongs;
const promoteValues =
Expand Down Expand Up @@ -238,6 +239,14 @@ class BinMsg {
}
}

// TODO: This is special-cased in the OP_RESPONSE code, but should probably
// be moved into Cursor logic.
if (this.documents.length === 1 && documentsReturnedIn != null && raw) {
_options.fieldsAsRaw = { [documentsReturnedIn]: true };
const doc = this.bson.deserialize(this.documents[0], _options);
this.documents = [doc];
}

this.parsed = true;
}
}
Expand Down

0 comments on commit f91304b

Please sign in to comment.