Open programarivm opened 6 years ago
Just added a MapFieldsTransformer
as described at this README.md in section Doctrine query with field transformation loaded into a table
I like the idea, posted my thoughts in https://github.com/umpirsky/Extraload/pull/17#discussion_r183299408. :+1:
Hi there,
Thanks for sharing Extraload with the community. It would be great if some more examples and documentation could be added to the library.
Why would we need a
MappingFieldsTransformer?
I noticed that many times we'll go like this.
Source
books
:isbn
,title
,author
Destination
my_books
:foo
,bar
In this example we're loading the contents of
books.isbn
intomy_books.foo
; the same thing goes forbooks.author
(we load its content intomy_books.bar
). And note thebooks.title
field is not used in the target table.The example above shows a
3 -> 2
mapping between the tablesbooks
andmy_books
because we want to (1) change the names of the fields in the target table and (2) be able to choose which source table fields are actually loaded into the destination table.More specifically, this
3 -> 2
mapping in particular could be described like this in theMappingFieldsTransformer
:I believe this is very common -- I'll soon share a
MappingFieldTransformer
if all this makes sense. In fact it would be good to have a bunch of common transformers:MappingFieldsTransfomer
TrimTransformer
...
And write a few more examples on using them.