Skip to content

Commit 13267f8

Browse files
authored
CSHARP-4786: Added shim to uuidhelpers.js so that it works in both the old mongo shell as well as the new mongosh shell. (#1175)
1 parent 6e6179f commit 13267f8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

uuidhelpers.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Javascript helper functions for parsing and displaying UUIDs in the MongoDB shell.
2-
// This is a temporary solution until SERVER-3153 is implemented.
32
// To create BinData values corresponding to the various driver encodings use:
43
// var s = "{00112233-4455-6677-8899-aabbccddeeff}";
54
// var uuid = UUID(s); // new Standard encoding
@@ -136,6 +135,12 @@ BinData.prototype.toHexUUID = function () {
136135
return 'HexData(' + this.subtype() + ', "' + uuid + '")';
137136
}
138137

138+
// for compatibility with the new mongosh shell
139+
if (BinData.prototype.base64 === undefined && BinData.prototype.subtype === undefined) {
140+
BinData.prototype.base64 = function() { return this.buffer.base64Slice(); };
141+
BinData.prototype.subtype = function() { return this.sub_type; };
142+
}
143+
139144
function TestUUIDHelperFunctions() {
140145
var s = "{00112233-4455-6677-8899-aabbccddeeff}";
141146
var uuid = UUID(s);

0 commit comments

Comments
 (0)