Skip to content

Commit

Permalink
Added ability to specify BSON subtype for the MongooseBuffer in toObj…
Browse files Browse the repository at this point in the history
…ect() method. Also added minor documenation specifying the subtype codes.
  • Loading branch information
Jarrett Cruger committed Jul 9, 2012
1 parent aedbb0f commit 056d7bf
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/types/buffer.js
Expand Up @@ -153,13 +153,22 @@ MongooseBuffer.prototype.copy = function (target) {


/** /**
* Returns a Binary. * 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} * @return {Buffer}
* @api public * @api public
*/ */


MongooseBuffer.prototype.toObject = function () { MongooseBuffer.prototype.toObject = function (subtype) {
return new Binary(this, 0x00); subtype = typeof subtype !== 'undefined' ? subtype : 0x00
return new Binary(this, subtype);
}; };


/** /**
Expand Down

0 comments on commit 056d7bf

Please sign in to comment.