Delete an e-smith property


(Stéphane de Labrusse) #1

Hi

I’m doing a migrate fragment like this way @dev_team

{
    # We want to migrate the IMAPLoginFieldName
    # property to CustomEmailField
    use esmith::ConfigDB;
    my $db = esmith::ConfigDB->open;

    my $sogod = $db->get('sogod');
    my $CustomEmailField = $sogod->prop('IMAPLoginFieldName');

    if ($CustomEmailField) {
        $db->set_prop('sogod','CustomEmailField',$CustomEmailField);
        $sogod->delete_prop('IMAPLoginFieldName');
    }
}

could it be possible (I assume that I need to do a feature request)

{
    # We want to migrate the IMAPLoginFieldName
    # property to CustomEmailField
    use esmith::ConfigDB;
    my $db = esmith::ConfigDB->open;

    my $CustomEmailField = $db->get_prop('sogod','IMAPLoginFieldName');

    if ($CustomEmailField) {
        $db->set_prop('sogod','CustomEmailField',$CustomEmailField);
        $db->del_prop('sogod','IMAPLoginFieldName');
    }
}

it is quicker :frowning:


(Giacomo Sanchietti) #2

I always liked this non-existing api! :smiley:

I don’t know if does it worth to implement, but in your case you can also use this code:

 $db->get_prop_and_delete('sogod','IMAPLoginFieldName');

(Stéphane de Labrusse) #3

thank for sharing it, indeed it is probably faster

I’m reading again the api :blush: