Permalink
Browse files

Merge pull request #1000 from jcrugzz/master

Specifying BSON SubType for the toObject() method in MongooseBuffer
  • Loading branch information...
2 parents 5656142 + 056d7bf commit 750ab5009ae3950b1fcf06811ffcb2911061cc25 @aheckmann aheckmann committed Jul 10, 2012
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);
};
/**

0 comments on commit 750ab50

Please sign in to comment.