As discussed in the slack, embedded noSQL relationships are not easily integratable in JsonapiCompliable module.
The current logic assumes a foreign_key is required to save associations, however Mongoid's embeds_one and embeds_many do not require the foreign key but the parent object itself. The nested objects are directly added as an attribute hash to the parent_object. It is almost as if it behaved as an attribute (with the big difference that embedded records are identified by an ID, indexable, and a special Mongoid proxy allows to use Active Model scopes on embedded relations)
In a nutshell, the resource #create, #update, and maybe even #destroy methods need a way to access the parent_object of the relation.
As discussed in the slack, embedded noSQL relationships are not easily integratable in JsonapiCompliable module.
The current logic assumes a
foreign_keyis required to save associations, however Mongoid'sembeds_oneandembeds_manydo not require the foreign key but the parent object itself. The nested objects are directly added as an attribute hash to the parent_object. It is almost as if it behaved as an attribute (with the big difference that embedded records are identified by an ID, indexable, and a special Mongoid proxy allows to use Active Model scopes on embedded relations)In a nutshell, the resource
#create,#update, and maybe even#destroymethods need a way to access theparent_objectof the relation.