odin icon indicating copy to clipboard operation
odin copied to clipboard

Mapping: Appending to list, Adding to dictionary

Open josephfinlayson opened this issue 1 year ago • 4 comments

I'm trying to map between two resources

class AirtableShopifyMapper(odin.Mapping):

    from_resource = AirTableProduct
    to_resource = ShopifyProduct

    @odin.map_list_field(from_field='wholesale_price', to_field='metafields')
    def wholesale_price(self, value):
        return ["wholesale_price"]

    
    @odin.map_list_field(from_field='sample_price', to_field='metafields')
    def sample_price (self, value):
        return ["sample_price"]

Specifically, I want to find out how to append to a field on the to_resource I can't work out how to do this. I've tried to access the to_object.metafields on self to keep appending, but I don't see it avaiable. Any tips?

josephfinlayson avatar Feb 23 '23 15:02 josephfinlayson