You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on a project that uses the MongooseMap type and thought one simple line would help within the get, set, and deleteinstance methods. We just add a short conversion onto the following functions:
This implicit cast would be more or less expected as ObjectId is so frequently represented as a string. This example just shows a case where data would be stored in conjunction with a list of references. We want to get the data upon user requests, and calling the user id on the Map's hash-table will obviously be faster than a linear scan (or at least less painfull to look at then a toString call every 10 seconds).
Add ObjectId conversion to map so we don't have to think about converting to string. Maintain object relationships with ObjectIds meant to represent other docs.
The text was updated successfully, but these errors were encountered:
Enchancment
I am working on a project that uses the
MongooseMap
type and thought one simple line would help within theget
,set
, anddelete
instance methods. We just add a short conversion onto the following functions:mongoose/lib/types/map.js
Lines 43 to 44 in aef25e0
mongoose/lib/types/map.js
Lines 51 to 52 in aef25e0
mongoose/lib/types/map.js
Lines 109 to 110 in aef25e0
Namely, insert:
Also require ObjectId in the header.
mongoose/lib/types/map.js
Lines 2 to 4 in aef25e0
Example
This implicit cast would be more or less expected as ObjectId is so frequently represented as a string. This example just shows a case where data would be stored in conjunction with a list of references. We want to get the data upon user requests, and calling the user id on the Map's hash-table will obviously be faster than a linear scan (or at least less painfull to look at then a
toString
call every 10 seconds).TL;DR
Add ObjectId conversion to map so we don't have to think about converting to string. Maintain object relationships with ObjectIds meant to represent other docs.
The text was updated successfully, but these errors were encountered: