We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to do what you see using the mgm library, but I couldn't figure it out.
[{ '$unwind': { 'path': '$nodes', 'includeArrayIndex': 'arrayIndex', 'preserveNullAndEmptyArrays': True } }, { '$lookup': { 'from': 'documents', 'localField': 'nodes.data.video', 'foreignField': '_id', 'as': 'results' } }, { '$match': { '_id': ObjectId('6560f9e87c9e42e241e29c62') } }]
func (w *Widget) Get(id string) (interface{}, error) { widget := &mongodb.Widget{} documentCollName := mgm.Coll(&mongodb.Document{}).Name() if cur, err := mgm.Coll(widget).Aggregate(mgm.Ctx(), bson.A{ bson.M{operator.Match: bson.M{field.ID: id}},// If I add this, no result is returned builder.S(builder.Unwind("$nodes", "arrayIndex", true)), builder.S(builder.Lookup(documentCollName, "nodes.data.video", "_id", "documents")), }); err == nil { results := []bson.M{} cur.All(mgm.Ctx(), &results) return results, nil } else { fmt.Println(err) } return widget, nil }
The text was updated successfully, but these errors were encountered:
mehran-prs
No branches or pull requests
I want to do what you see using the mgm library, but I couldn't figure it out.
The text was updated successfully, but these errors were encountered: