You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an important one for Data Mappers to implement. It's one of the primary reasons to use a Data Mapper over an Active Record.
This also makes database migrations a lot less of a necessity since if you need to rename something on your model, there isn't a corresponding database change.
Determine how to serialize different types of queries
Given the following query on a Postgres database: mapper.select { |article| article.author.name == 'Jamie' }
If the author attribute is referenced, we could do a JOIN and not only get that article, but side-load the author, as well.
If the author is embedded, we would know that it is serialized as JSON and use the appropriate operators to dig into it and retrieve its name attribute.
This could also extend to doing things like this to find articles with specific tags: mapper.select { |article| article.tags.any? { |tag| tag == 'perpetuity' } }
Passing the class->table mapping will become important once we support mapping to a different table than the class name, as well, so when we do JOIN queries we're able to join the right table.
The text was updated successfully, but these errors were encountered:
If we pass attributes defined in the mapper to the queries, this will allow us to do several different things:
mapper.select { |article| article.author.name == 'Jamie' }
author
attribute is referenced, we could do aJOIN
and not only get that article, but side-load the author, as well.author
is embedded, we would know that it is serialized as JSON and use the appropriate operators to dig into it and retrieve itsname
attribute.mapper.select { |article| article.tags.any? { |tag| tag == 'perpetuity' } }
JOIN
queries we're able to join the right table.The text was updated successfully, but these errors were encountered: