-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ObjectId not working when using object id in nested collection #6808
Comments
@sumitLKpatel Thanks for posting! We'll take a look as soon as possible. In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly. For help with questions about Sails, click here. |
@sumitLKpatel - In your
|
@johnabrams7 |
@sumitLKpatel Sounds good and thanks for the info so far. If you don't mind, can you reproduce this in a new Sails v1.x app repo with only one model? Also, can you include instructions for creating a mongo record that causes this error? |
Hi, @sumitLKpatel! Thanks for those screenshots; those are super helpful. I believe that your issue is arising from the use of Let me know if this works for you! |
@MadisonHicks AdapterError: Unexpected error from database adapter: object [{"_bsontype":"ObjectID","id":null}] is not a valid ObjectId so i don't think there is any issue is related to .fetch(), the issue is mongo-adapter thawing error while i'm going to update my those records which have nested objectIds. and when i convert those objectIds in to string, then it works....but i don't wan't to convert because there is lot data available like this in my database colections |
Hey, @sumitLKpatel! Sorry, I should have been more thorough in my last comment—the default result of Per the upgrade guide:
The |
@MadisonHicks |
Hey, @sumitLKpatel— Can you create a new Sails app with a single model that reproduces this error, and include a brief description of the action you're taking to trigger the error? I'd like to be able to help, and I think that this might help me better understand your issue. |
Hey @MadisonHicks here is repo, you can check it. https://github.com/sumitLKpatel/sails-mongo-issue |
Hey, @sumitLKpatel— I'm getting errors when I |
yes it's working for me perfectly.... |
@sumitLKpatel—cool, it's just on my end, then. I'll spend some time with this as soon as I get a chance. |
Hey, @sumitLKpatel—sorry for the radio silence. I just chatted with the rest of the team, and our recommendation is to use strings instead of object IDs. We think that your problem may be that objectID instances are being passed into nested JSON. |
@MadisonHicks |
@sumitLKpatel—yeah, that sounds like it would be super inconvenient for you. Can you share a little bit more about your use case? We'd love to help you find a workaround. |
Hi @sumitLKpatel , i experienced the same issue recently. I was working with sails and it has a hook of beforeCreate that is executed before the model document is created in its collection. e.g. it never gave me any trouble afterwards. If you have some issue in fetching it, perhaps you can convert at the time of retrieval. Hope it helps |
I'm in a Sails 0.12 to 1.x-transition and have the same problem. After migrating several projects to Sails 1.x, my honest opinion is that Sails (Waterline) is no longer very well suited for use with MongoDB databases. It doesn't support storing even basic data structures (like arrays) with id's in them, mutates returned objects, doesn't allow geo-queries etc. Also, the My workaround is to get a native db connection with |
Hey, @stensrud! Thanks for the input and workaround. It seems like using native tools will, indeed, be the best option for functionality not supported by Waterline. Other community input on this topic is welcome! |
Nope. Even Native update query ends up with the same error. |
Node version: v8.16.0
Sails version (sails): 1.2.3
Sails Mongo (sails-mongo): 1.0.1
my app was working in old sails were i used object id in nested collection , and now i did rewrite my app in latest sails, now it's not working with old collection, it's giving error like
AdapterError: Unexpected error from database adapter: object [{"_bsontype":"ObjectID","id":null}] is not a valid ObjectId
this is happening when i try to use objectId in nested collection. please fix it ASAP because it's really hard to me to go live with this code.
The text was updated successfully, but these errors were encountered: