lukaswilkeer / reproduce-hex-string-issue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reproduce-hex-string-issue

Reproduceble example of toHexString problem.

This issue was referenced at automattic/mongoose #8423

The problem could be solved using a middleware on get method of a model to convert the string of a BSON type to a hex string on init of project. using the method toString(), removing the timestamp and the random number, or using toHexString() of a BSON buffer. Mentioned here.

[quote]

// Works if you put this line here
mongoose.ObjectId.get(v => v.toString());

To test:

npm install

npm test

Before you'll need to import the mongo data, using mongoimport:

mongoimport --db=blink --collection=clocks

Status

Current fixed using .id intead ._id method.

About


Languages

Language:JavaScript 100.0%