Golang mongodb 构建引用关系

The*_*ner 6 go mongodb mongo-go gqlgen

我在 graphql 中与 Mongo go 驱动程序有这种一对多的引用关系。

type User {
    id: ObjectID!
    email: String!
    username: String!
    posts: [Post!]!
}

type Post {
    id: ObjectID!
    author: User!
    title: String!
    content: String!
}
Run Code Online (Sandbox Code Playgroud)

我知道我可以使用Aggregate框架来查询引用关系。

但是,如果我想创建用户同时也创建帖子怎么办?

collection.InsertOne在解析器中发送两个?