Specifying BSON SubType for the toObject() method in MongooseBuffer #1000

Merged
merged 1 commit into from Jul 10, 2012

Conversation

Projects
None yet
3 participants
@jcrugzz

jcrugzz commented Jul 9, 2012

Added a small snippet to be able to use various subtypes when dealing with binary data. By default it was just using the general subtype 0x00. Let me know what you think.

@aheckmann

View changes

examples/schema.js
@@ -73,7 +73,7 @@ BlogPost.statics.findByTitle = function (title, callback) {
}
BlogPost.methods.expressiveQuery = function (creator, date, callback) {
- return this.find('creator', creator).where('date').gte(date).run(callback);
+ return this.find('creator', creator).where('date').get(date).run(callback);

This comment has been minimized.

Show comment Hide comment
@aheckmann

aheckmann Jul 9, 2012

Collaborator

please remove this change.

@aheckmann

aheckmann Jul 9, 2012

Collaborator

please remove this change.

This comment has been minimized.

Show comment Hide comment
@jcrugzz

jcrugzz Jul 9, 2012

Makes sense, undid that part of the commit

@jcrugzz

jcrugzz Jul 9, 2012

Makes sense, undid that part of the commit

@@ -153,13 +153,14 @@ MongooseBuffer.prototype.copy = function (target) {
/**
* Returns a Binary.
- *
+ * @param {Hex} BSON SubType

This comment has been minimized.

Show comment Hide comment
@aheckmann

aheckmann Jul 9, 2012

Collaborator

can you add some docs around this, possible values, what they mean etc.

@aheckmann

aheckmann Jul 9, 2012

Collaborator

can you add some docs around this, possible values, what they mean etc.

This comment has been minimized.

Show comment Hide comment
@jcrugzz

jcrugzz Jul 9, 2012

Added the specific subtypes and threw in a link to the BSON Spec

@jcrugzz

jcrugzz Jul 9, 2012

Added the specific subtypes and threw in a link to the BSON Spec

This comment has been minimized.

Show comment Hide comment
@zedgu

zedgu May 30, 2013

Contributor

new subtype of UUID is 0x04, and MD5 is 0x05, see http://bsonspec.org/#/specification

@zedgu

zedgu May 30, 2013

Contributor

new subtype of UUID is 0x04, and MD5 is 0x05, see http://bsonspec.org/#/specification

This comment has been minimized.

Show comment Hide comment
@aheckmann

aheckmann Jun 1, 2013

Collaborator

we should remove these from the docs and just keep the link to bsonspec.org.

@aheckmann

aheckmann Jun 1, 2013

Collaborator

we should remove these from the docs and just keep the link to bsonspec.org.

Jarrett Cruger
Added ability to specify BSON subtype for the MongooseBuffer in toObj…
…ect() method. Also added minor documenation specifying the subtype codes.

aheckmann added a commit that referenced this pull request Jul 10, 2012

Merge pull request #1000 from jcrugzz/master
Specifying BSON SubType for the toObject() method in MongooseBuffer

@aheckmann aheckmann merged commit 750ab50 into Automattic:master Jul 10, 2012

@aheckmann

This comment has been minimized.

Show comment Hide comment
@aheckmann

aheckmann Jul 10, 2012

Collaborator

thanks. merged! btw, can you give me some insight how this helps your use case? I've never messed with subtypes.

Collaborator

aheckmann commented Jul 10, 2012

thanks. merged! btw, can you give me some insight how this helps your use case? I've never messed with subtypes.

@jcrugzz

This comment has been minimized.

Show comment Hide comment
@jcrugzz

jcrugzz Jul 10, 2012

Was overriding the _id field to use UUIDs over the objectId for my objects. I saw it was still possible to use mongoose in order to do this but that the default MongoseBuffer object was created using the 0x00 subtype for the binary automatically. Thought I'd implement the change to get whatever extra little optimization I can from clarifying the subtype. My particular object creation is as follows: var model = new Model({_id: new MongooseBuffer(uuidString).toObject(0x03), other: val});

jcrugzz commented Jul 10, 2012

Was overriding the _id field to use UUIDs over the objectId for my objects. I saw it was still possible to use mongoose in order to do this but that the default MongoseBuffer object was created using the 0x00 subtype for the binary automatically. Thought I'd implement the change to get whatever extra little optimization I can from clarifying the subtype. My particular object creation is as follows: var model = new Model({_id: new MongooseBuffer(uuidString).toObject(0x03), other: val});

@aheckmann

This comment has been minimized.

Show comment Hide comment
@aheckmann

aheckmann Jul 10, 2012

Collaborator

hm, i wonder if this shouldn't be a schema option for the buffer type

Collaborator

aheckmann commented Jul 10, 2012

hm, i wonder if this shouldn't be a schema option for the buffer type

@jcrugzz

This comment has been minimized.

Show comment Hide comment
@jcrugzz

jcrugzz Jul 11, 2012

what do you mean exactly?

jcrugzz commented Jul 11, 2012

what do you mean exactly?

@aheckmann

This comment has been minimized.

Show comment Hide comment
@aheckmann

aheckmann Jul 11, 2012

Collaborator

just thinking that since there are different binary subtypes, we could allow specifying this in the schema type so its stored transparently.

Schema({ buf: { type: Buffer, subtype: 0x03 }})

Collaborator

aheckmann commented Jul 11, 2012

just thinking that since there are different binary subtypes, we could allow specifying this in the schema type so its stored transparently.

Schema({ buf: { type: Buffer, subtype: 0x03 }})

@aheckmann

This comment has been minimized.

Show comment Hide comment
@aheckmann

aheckmann Jul 11, 2012

Collaborator

probably just leave it out for now unless people need it someday

Collaborator

aheckmann commented Jul 11, 2012

probably just leave it out for now unless people need it someday

@jcrugzz

This comment has been minimized.

Show comment Hide comment
@jcrugzz

jcrugzz Jul 11, 2012

It does make more sense from an implementation standpoint. I'll get to it at some point.

jcrugzz commented Jul 11, 2012

It does make more sense from an implementation standpoint. I'll get to it at some point.

@zedgu zedgu referenced this pull request May 31, 2013

Closed

Just found a little bug. #1517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment