-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
find by ObjectID fails #23
Comments
This handles deserialization of ObjectIDs, also need to serialize any client-side provided IDs into ObjectIDs. |
Yes, see #22 for the serialization, I ran into this afterwards. |
There needs to be a configuration option whether to use ObjectIDs globally or not. The problem is that they can not be mixed, since one must always cast strings to ObjectIDs. |
Agreed, I tried to make it work as a mix, but for various reasons I no longer think that is a good idea / possible. I was running out of time and I ended up switching over to using strings instead of ObjectIDs for the time being. A configuration to use Object IDs globally is a good idea! |
Related to #5; if the ID field is an ObjectID, find fails.
For example:
http://localhost:1337/foo/59c84caa76f5f2066ae21d9a
http://localhost:1337/foo/_bsontype,ObjectID,id,Y%EF%BF%BDL....
The id field is always treated as a string in the resulting query.
fortune-mongodb/lib/index.js
Line 122 in 7e8c626
There is not much to differentiate a serialized ObjectID from a normal string.
One approach would be to attempt to de-serialize the ID into an ObjectID.
If this de-serialization is successful, add the resulting object as an alternative to the lookup query.
This works and all variations are covered:
http://localhost:1337/foo/59c84caa76f5f2066ae21d9a
http://localhost:1337/foo/bar
or any other string including the IDs that get generated by Fortune itself.
Thoughts?
The text was updated successfully, but these errors were encountered: