Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Specifying BSON SubType for the toObject() method in MongooseBuffer #1000
Conversation
aheckmann
reviewed
Jul 9, 2012
View changes
@@ -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
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
aheckmann
reviewed
Jul 9, 2012
@@ -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
This comment has been minimized.
Show comment
Hide comment
aheckmann
Jul 9, 2012
Collaborator
can you add some docs around this, possible values, what they mean etc.
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
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
zedgu
May 30, 2013
Contributor
new subtype of UUID is 0x04, and MD5 is 0x05, see http://bsonspec.org/#/specification
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
This comment has been minimized.
Show comment
Hide comment
aheckmann
Jun 1, 2013
Collaborator
we should remove these from the docs and just keep the link to bsonspec.org.
aheckmann
Jun 1, 2013
Collaborator
we should remove these from the docs and just keep the link to bsonspec.org.
added a commit
that referenced
this pull request
Jul 10, 2012
aheckmann
merged commit 750ab50
into
Automattic:master
Jul 10, 2012
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
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.
thanks. merged! btw, can you give me some insight how this helps your use case? I've never messed with subtypes. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
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: |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
aheckmann
Jul 10, 2012
Collaborator
hm, i wonder if this shouldn't be a schema option for the buffer type
hm, i wonder if this shouldn't be a schema option for the buffer type |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
jcrugzz
commented
Jul 11, 2012
what do you mean exactly? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
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 }})
just thinking that since there are different binary subtypes, we could allow specifying this in the schema type so its stored transparently.
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
aheckmann
Jul 11, 2012
Collaborator
probably just leave it out for now unless people need it someday
probably just leave it out for now unless people need it someday |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
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. |
jcrugzz commentedJul 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.