I keep getting this error. What do I write to handle relational data? Does anyone know?

// 处理关联集合
const actorIds = await this.handleRelations(stars, ‘api::actor.actor’, ‘name’);
const categoryIds = await this.handleRelations([category], ‘api::category.category’, ‘name’);
const tagIds = await this.handleRelations(tags, ‘api::tag.tag’, ‘name’);

// 处理组件类型
const m3u8pathsComponent = m3u8paths ? { hd: m3u8paths.hd, path: m3u8paths.path } : null;
const poster2Component = poster2 ? { url: poster2.url, height: poster2.height, width: poster2.width } : null;
const screenshotsComponent = screenshots.map((url) => ({ url }));

async handleRelations(names: any, uid, field) {
const ids: string = ;
const namesAsStrings = names as string; // 类型断言

for (const name of namesAsStrings) {
  const [item] = await strapi.entityService.findMany(uid, {
    filters: { [field]: name },
  });

  if (item) {
    ids.push(item.id.toString()); // 将 ID 转换为字符串类型
  } else {
    const createdItem = await strapi.entityService.create(uid, { data: { [field]: name } });
    ids.push(createdItem.id);
  }
}

return ids;

}
}));
The type “GetValues<any, string> | GetValues<any, string>” must have a “Symbol.iterator” method that returns an iterator.

This topic has been created from a Discord post (1248286723104837693) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord