Implement embeds_many / one
thhermansen opened this issue · comments
Some thoughts and code examples (wip):
class Car < MassiveRecord::ORM::Embedded
embedded_in :person
end
class Person < MassiveRecord::ORM::Table
# As a default, these embedded objects are stored in it's own family; cars.
# Or, you can give :store_in => 'my_cars' if you want to.
embeds_many :cars
end
Car's id will be prefixed with the class name, rest will be time in ms as a default.
Investigate if we can get one record / scan multiple via Thrift, applying limits etc.
Maybe add a counter.
So this is moving forward in this branch. Right now embedding works, but there are something which does not. So here comes a todo list for myself:
- (Done) Validations / handle save if any embedded records becomes invalid after being added to the collection.
- (Done) Double check this one, when parent and embedded are saved, embedded are invalidated, and then parent is asked to be saved. :-)
- (Done) Timestamps (check how it behaves as I kinda don't know if it works 100% as expected).
- (Done) Reload embedded record does not work.
- (Done) Generate ids for embedded objects.