orlandos-nl / MongoKitten

Native MongoDB driver for Swift, written in Swift

Home Page:https://orlandos.nl/docs/mongokitten/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pipeline stage naming

Obbut opened this issue · comments

I would like to discuss the naming of pipeline stages in MongoKitten. Currently, the stages are named like this:

let pipeline: AggregationPipeline = [
                .grouping("$state", computed: ["totalPop": .sumOf("$pop")]),
                .matching("totalPop" > 10_000_000),
                .sortedBy(["totalPop": .ascending]),
                .projecting(["_id": false, "totalPop": true]),
                .skipping(2)
            ]

While it's just a small detail, I personally would prefer this:

let pipeline: AggregationPipeline = [
                .group("$state", computed: ["totalPop": .sumOf("$pop")]),
                .match("totalPop" > 10_000_000),
                .sort(["totalPop": .ascending]),
                .project(["_id": false, "totalPop": true]),
                .skip(2)
            ]

I think that looks better, because:

  • it is more consistent with the MongoDB stage naming
  • aggregation pipeline stages can be seen as a sort of function that is executed, and I think that a function to match things would be called match, not matching, so that feels weird to me
  • I personally find it easier to read, but that may not be the case for everyone

What's your opinion on this?

I'm agree. It looks better and It concordant with MongoDB aggregation operators syntax.

Totally agree. Follow the same naming of syntax as per Mongo itself.

Implemented