Skip to content

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

Open
@0x123456789

Description

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions