Skip to content
New issue

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

Is SimpleAggregate order-safe while do pipeline operations? #93

Open
0x123456789 opened this issue Feb 18, 2024 · 0 comments
Open

Is SimpleAggregate order-safe while do pipeline operations? #93

0x123456789 opened this issue Feb 18, 2024 · 0 comments
Assignees

Comments

@0x123456789
Copy link

Hi, as I can see in different tutorials (ex. https://www.mongodb.com/blog/post/quick-start-golang--mongodb--data-aggregation-pipeline) they use mongo.Pipeline which is []bson.D. In code for SimpleAggregateCursorWithCtx pipeline is bson.A (not bson.D which is ordered):

func (coll *Collection) SimpleAggregateCursorWithCtx(ctx context.Context, stages ...interface{}) (*mongo.Cursor, error) {
	pipeline := bson.A{}

	for _, stage := range stages {
		if operator, ok := stage.(builder.Operator); ok {
			pipeline = append(pipeline, builder.S(operator))
		} else {
			pipeline = append(pipeline, stage)
		}
	}

	return coll.Aggregate(ctx, pipeline, nil)
}

Can you please say, if I want aggregation with $match at first and $lookup, can I use SimpleAggragation methods?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants