jedireza / mongo-models

:package: Map JavaScript classes to MongoDB collections
MIT License
67 stars 28 forks source link

*byId methods don't work with custom IDs #31

Closed olhapi closed 6 years ago

olhapi commented 6 years ago

I always get Argument passed in must be a single String of 12 bytes or a string of 24 hex characters error when trying to use *byId methods of mongo-models with custom IDs (for example: D1, D4).

jedireza commented 6 years ago

Did you set the _idClass property with your constructor?

Docs: https://github.com/jedireza/mongo-models/blob/master/API.md#_idclass

Example using String instead of MongoDB.ObjectID: https://github.com/jedireza/frame/blob/b59761b1ea73a4eac257a676c06b4909547c99db/server/models/status.js#L33