niahmiah / mongoose-uuid

uuid type for mongoose
21 stars 24 forks source link

Problem with different finds on model #10

Closed thxmike closed 6 years ago

thxmike commented 6 years ago

I documented this problem https://stackoverflow.com/questions/48491035/mongoose-does-not-return-id-in-findone?noredirect=1#comment83977280_48491035

It works great with instances of the model (document) however, when I do a find on an object, the returned object returns from the database but fails to push _id into the schema and states Could not cast �*.��F����G�U` to uuid

Not sure how to fix this one.

jubeiam commented 6 years ago

As i'm unable to reply on stack i'm writing it here. Try to use mongoose v4 not v5. I had similar problem on new release.

thxmike commented 6 years ago

OK Checking Mongoose v4

thxmike commented 6 years ago

I checked using Mongoose v4. This was a problem since v4 does not support the ES6 constructs and fails on LoadClass.

sbesedkov commented 6 years ago

@thxmike replied to your post on stack: https://stackoverflow.com/a/48663223/1714542

The problem is here https://github.com/niahmiah/mongoose-uuid/blob/bfa1b5ad3536b067cac19456eabac2af64beac86/index.js#L100

It occurs when your major version of mongoose differs from the mongoose-uuid's one.

thxmike commented 6 years ago

I ended up creating a fork of this repo and updated the bson and mongoose packages. https://github.com/thxmike/mongoose-uuid. I then updated the code to the use the new bson contracts in the naming of the types. I understand why are limited to doing it this way. Basically it is for backwards compatibility. I attempted to pull request this into the repo but since you support the node 0.10, it fails due to mongoose using ES6 construct. I will use my forked version until I can spend more time on this for an alternate solution.

niahmiah commented 6 years ago

Thanks thxmike!