Description
Is your feature request related to a problem? Please describe.
How to use builder.Lookup
with SimpleAggregate
?
Describe the solution you'd like
Please add one more example using SimpleAggregate with builder.Lookup
into
https://github.com/Kamva/mgm/blob/master/examples/aggregate/aggregate.go
Describe alternatives you've considered
Additional context
I tried it myself, adding the following to the top of func lookup(), after:
mgm/examples/aggregate/aggregate.go
Lines 24 to 27 in aff6e8d
{
authorCollName := mgm.Coll(&author{}).Name()
result := []book2{}
_ := mgm.Coll(&book{}).SimpleAggregate(&result, builder.Lookup(authorCollName, "auth_id", "_id", "author"))
fmt.Printf("1] %+v\n", result)
}
after defining book2
as:
type book2 struct {
book
author []author
}
However, what get printed was:
1] [{book:{DefaultModel:{IDField:{ID:ObjectID("000000000000000000000000")} DateFields:{CreatedAt:0001-01-01 00:00:00 +0000 UTC UpdatedAt:0001-01-01 00:00:00 +0000 UTC}} Name: Pages:0 AuthorID:ObjectID("000000000000000000000000")} author:[]}]
I.e., the lookup field author
was empty, and so is the returned book, but the SimpleAggregate
didn't return any error (I checked).
Please help.
Activity