Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added ability to specify BSON subtype for the MongooseBuffer in toObj…

…ect() method. Also added minor documenation specifying the subtype codes.
  • Loading branch information...
commit 056d7bf1ed690af50b316fc8a3e6334d79b682b1 1 parent aedbb0f
Jarrett Cruger authored
Showing with 12 additions and 3 deletions.
  1. +12 −3 lib/types/buffer.js
View
15 lib/types/buffer.js
@@ -153,13 +153,22 @@ MongooseBuffer.prototype.copy = function (target) {
/**
* Returns a Binary.
- *
+ * @param {Hex} BSON SubType
+ * SubTypes:
+ * 0x00: Binary/Generic
+ * 0x01: Function
+ * 0x02: Binary (Deprecated, 0x00 is new default)
+ * 0x03: UUID
+ * 0x04: MD5
+ * 0x80: User Defined
+ * More info here: http://bsonspec.org/#/specification
* @return {Buffer}
* @api public
*/
-MongooseBuffer.prototype.toObject = function () {
- return new Binary(this, 0x00);
+MongooseBuffer.prototype.toObject = function (subtype) {
+ subtype = typeof subtype !== 'undefined' ? subtype : 0x00
+ return new Binary(this, subtype);
};
/**
Please sign in to comment.
Something went wrong with that request. Please try again.