-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Mongodb support for non-existent field #471
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
Conversation
Mongodb has no fixed structure for collections. So a field may be non-existent in mongodb. In this case, the property that represents the foreignKey cannot be retrieved and an ErrorException will be thrown. I've added a try-catch construct to avoid the case in which the field doesn't exists.
2 similar comments
2 similar comments
In what case would you get this error? |
I've no foreign keys fields for some documents in a collection. The foreign keys fields are inserted progessively by a laravel application. I think this problem comes up because I've first inserted the documents inside some collections, then I've defined the relations between them. |
Could you show me a code example when this would happen? I will be able to add it to the tests then and fix it more easily :) |
Just define your model without relations:
Then use the model in your code to populate the collection. You want to add another collection for the So you add the
Add now add an inverse relation to the model
You expected to work with the field
you get an The above code fails because Consider the case in which I want to add some one-to-many relations to my collections and my data cannot be touched because they are used daily by my clients (through my production systems). This is the context in which this error happen and I think the same behaviour can be extended to other inverse relations. |
Any news of this? |
Mongodb has no fixed structure for collections. So a field may be non-existent in mongodb.
In this case, the property that represents the foreignKey cannot be retrieved and an ErrorException will be thrown.
I've added a try-catch construct to avoid the case in which the field doesn't exists.