save/get data from map field type What I want to do is give a possibility to the user to save as many images as he likes. For this, I have created a specific field type

    $fields['photo_ids'] = BaseFieldDefinition::create('map')
  -&gt;setLabel(t('Photos'))
  -&gt;setDescription(t('The photo ids of the Item entity.'))
  -&gt;setSettings([
    'max_length' =&gt; 50,
    'text_processing' =&gt; 0,
  ])
  -&gt;setDefaultValue('');


here I want to save, add, delete IDs of pictures. Not sure if this is the best approach to this problem. The problem is I can't find the way in Drupal 8 to serialize/deserialize and save these data into the database;
You should not create your content type programmatically, if there's no special reason. Take a look at any intro like this https://www.youtube.com/watch?v=Nfu6nckjuno - then create a content type and fields with the excellent admin UI.

Serialization to DB is done by the Drupal core.