code: def _add_to_index(index, obj):
      
      id_set = index.value_map.setdefault(indexed_value(index, obj), set())
      if index.unique:
          if len(id_set) > 0:
              raise UniqueConstraintError()
      id_set.add(obj.id)
docs: Adds the given object ``obj`` to the given ``index``