Directus 版本:11.7.2
集合A:games,含 title、category 等游戏信息字段:
games: { title, category: { name, slug }, ... }
集合B:tags,含:name,slug,games,其中 games 通过 M2M 关联到 games 的 id,并且创建集合时要勾选 Add M2M to “games”,这样 games 里会增加一个关联字段,默认是 tags:
tags: { name, slug, games },
games: { ... tags }
假设批量修改若干 games 的 tags:
POST /graphql
mutation {
update_games_items(
ids: [ 1,2,3 ]
data: {
tags: {
tags_id: {
id: 1
}
}
}
) {
id
tags {
id
}
}
}