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%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec generate (binary()) -> map_map:type().
generate (OwnerID) ->
   Map = map_map:default(OwnerID),
   {ok, MapID} =
      shr_database:insert
      (
         map_db,
         any,
         [{user, OwnerID}],
         Map
      ),
   MapSummary = shr_map_summary:new(<<"Untitled Map">>, MapID),
   PlayerUpdateQueryOps =
      [
         %% FIXME: shr_db_query:add_to_field handles lists,
         %% shr_player:get_map_summaries_field() points to an array.
         shr_db_query:add_to_field
         (
            shr_player:get_map_summaries_field(),
            [MapSummary],
            false
         )
      ],
   ok =
      shr_database:commit
      (
         shr_db_query:new(player_db, OwnerID, admin, PlayerUpdateQueryOps)
      ),
   Map.
 |