https://github.com/luislobo/sails-mongo-error-find-id
Error when finding a document by a property that looks like an ObjecId, but its not.
https://github.com/luislobo/sails-mongo-error-find-id
Last synced: about 1 year ago
JSON representation
Error when finding a document by a property that looks like an ObjecId, but its not.
- Host: GitHub
- URL: https://github.com/luislobo/sails-mongo-error-find-id
- Owner: luislobo
- Created: 2014-05-08T23:41:26.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-08T23:51:09.000Z (about 12 years ago)
- Last Synced: 2025-03-24T05:51:56.209Z (about 1 year ago)
- Language: JavaScript
- Size: 238 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
I happen to have attribute values in a document that looks like a mongodb object id, but it's not. I defined it as a string.
Whenever I try to find it, it is not found, as it is converted by find into an ObjectId (as far as I've seen, in lib/query/index.js, function ParseTypes.
So, how can I query my STRING attribute (notice, its not a model attribute), that has a similar format to a MongoDB id?
I think the ParseTypes should be more intelligent, like checking the schema, if the attribute type is model... or something like that.
if you lift and run
http://localhost:1337/document/working
you will see in the console a document created and a document found
http://localhost:1337/document/notworking
you will see in the console a document created and a document NOT found
Check Issue: https://github.com/balderdashy/sails-mongo/issues/143