我有两个“链接”的POJO实体:
public class User {
public ObjectId id; // this is mapped to "_id" in the MongoDB
public String userName;
...
}
public class Purchase {
public ObjectId id; // this is mapped to "_id" in the MongoDB
public ObjectId userId;
public transient Use
我的MongoDB数据库中有许多集合。聚合工作很好,但我不能将一些字段推送到所需的输出,
收藏品A是:
{
_id: some mongodbID
//...fields
items: [
{
_id: someId,
color: someId <---- Im aggregate this with lookup
neededFieldToPush: 123
},
{
_id: someId,
color: someId <---- Im aggregate this with lookup
我有这两个结构:
Category struct {
ID primitive.ObjectID `bson:"_id"`
Name string `bson:"name"`
}
Book struct {
ID primitive.ObjectID `bson:"_id"`
Name string `bson:"name"`
Category *Category