-
Notifications
You must be signed in to change notification settings - Fork 82
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
Embed by Reference Support #184
Comments
Unfortunately, this is not doable without a bunch of custom code. You should be able to pull it off, if you use |
Thank you and that's good to hear. I've looked at the code, but would it be possible to point me in the right direction? I am not sure how to insert a query in a before_save. I'm surprised no one has asked about this. |
@paul-uulabs looks like you might be able to use before_save and flip the association. Checkout: https://github.com/anlek/mongify/blob/master/lib/mongify/database/table.rb#L52 |
Thanks @anlek, I managed to use before_save to embed address references in companies, like I want... BUT the company record is still embedded into addresses in the end... so I end up with address>company>address ... if I could update the company table and stop the embed, I'd have what I want (company>address)... I am not sure if that is what you meant by "flip the association" ..? I cannot flip the tables completely (i.e.: rename "address" tables as "company", embed, and finally move the fields around) because addresses are referenced by several tables, not just companies... I don't know if it is possible to access the table object in before_save to embed the address record into the company collection, etc..? This is what I have...?
Also, I found a limitation in before_save... notice that my properties in addresses include "address1" and "address2"... Mongify strips out numeric characters in fields in data_row.rb so I could not access them in before_save unless I renamed them. |
The current table-level embed_in implementation requires the child to reference the parent by id... but there seems to be no way to embed if the parent references the child...
For example, the following will create a reference to an address (child) within "companies" (parent):
... BUT I want to embed the address record in companies... companies has a reference to address only.
Is it possible for Mongify to embed by reference... ?
For example, it would be great if I could do this on the column level:
column "addressId", :integer, :references => :addresses, embed_in=>true
... or maybe there is a way of doing this that I don't understand?
The text was updated successfully, but these errors were encountered: