From 39224b6fa3bf421cb20060b2c5235762671c3d57 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 18 Feb 2025 13:08:42 +0100 Subject: [PATCH 1/2] WIP --- generator/config/expression/gt.yaml | 2 +- generator/config/schema.json | 14 +++++++------- generator/config/stage/project.yaml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/generator/config/expression/gt.yaml b/generator/config/expression/gt.yaml index ddd4dcdd0..da3a35bb2 100644 --- a/generator/config/expression/gt.yaml +++ b/generator/config/expression/gt.yaml @@ -14,7 +14,7 @@ arguments: - name: expression2 type: - - expression + - expression # lack of backreferral is an issue here tests: - name: 'Example' diff --git a/generator/config/schema.json b/generator/config/schema.json index 63739ebcb..97ef1ce15 100644 --- a/generator/config/schema.json +++ b/generator/config/schema.json @@ -52,17 +52,17 @@ } }, "encode": { - "$comment": "Specifies how operator parameters are encoded.", - "$comment": "array: parameters are encoded as an array of values in the order they are defined by the spec", - "$comment": "object: parameters are encoded as an object with keys matching the parameter names", - "$comment": "single: get the single parameter value", - "$comment": "group: specific for $group stage", + "$comment": [ + "Specifies how operator parameters are encoded.", + "array: parameters are encoded as an array of values in the order they are defined by the spec", + "object: parameters are encoded as an object with keys matching the parameter names", + "single: get the single parameter value" + ], "type": "string", "enum": [ "array", "object", - "single", - "search" + "single" ] }, "description": { diff --git a/generator/config/stage/project.yaml b/generator/config/stage/project.yaml index c7b0f7d59..bde7c420d 100644 --- a/generator/config/stage/project.yaml +++ b/generator/config/stage/project.yaml @@ -11,7 +11,7 @@ arguments: name: specification type: - expression - variadic: object + variadic: object # XXX: This should somehow allow explicit typings for { fieldName: 1|0 } tests: - name: 'Include Specific Fields in Output Documents' From 56a801b2570876050f63058eface5b8cd645bca8 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Mon, 7 Apr 2025 11:06:37 +0200 Subject: [PATCH 2/2] add tests schema --- generator/config/accumulator/accumulator.yaml | 66 ++++-- generator/config/accumulator/addToSet.yaml | 86 +++++-- generator/config/accumulator/avg.yaml | 77 ++++-- generator/config/accumulator/bottom.yaml | 52 ++++- generator/config/accumulator/bottomN.yaml | 84 +++++-- generator/config/accumulator/count.yaml | 70 +++++- .../config/accumulator/covariancePop.yaml | 44 +++- .../config/accumulator/covarianceSamp.yaml | 44 +++- generator/config/accumulator/denseRank.yaml | 66 +++++- generator/config/accumulator/derivative.yaml | 28 ++- .../config/accumulator/documentNumber.yaml | 34 ++- .../config/accumulator/expMovingAvg.yaml | 48 +++- generator/config/accumulator/first.yaml | 70 +++++- generator/config/accumulator/firstN.yaml | 143 +++++++----- generator/config/accumulator/integral.yaml | 32 ++- generator/config/accumulator/last.yaml | 49 +++- generator/config/accumulator/lastN.yaml | 110 ++++++--- generator/config/accumulator/linearFill.yaml | 36 ++- generator/config/accumulator/locf.yaml | 18 +- generator/config/accumulator/max.yaml | 74 ++++-- generator/config/accumulator/maxN.yaml | 86 +++++-- generator/config/accumulator/median.yaml | 56 ++++- .../config/accumulator/mergeObjects.yaml | 53 ++++- generator/config/accumulator/min.yaml | 70 +++++- generator/config/accumulator/minN.yaml | 86 +++++-- generator/config/accumulator/percentile.yaml | 122 +++++++--- generator/config/accumulator/push.yaml | 78 +++++-- generator/config/accumulator/rank.yaml | 66 +++++- generator/config/accumulator/shift.yaml | 74 +++++- generator/config/accumulator/stdDevPop.yaml | 66 +++++- generator/config/accumulator/stdDevSamp.yaml | 62 ++++- generator/config/accumulator/sum.yaml | 78 +++++-- generator/config/accumulator/top.yaml | 52 ++++- generator/config/accumulator/topN.yaml | 84 +++++-- generator/config/expression/abs.yaml | 24 +- generator/config/expression/acos.yaml | 28 ++- generator/config/expression/acosh.yaml | 18 +- generator/config/expression/add.yaml | 60 ++++- .../config/expression/allElementsTrue.yaml | 36 ++- generator/config/expression/and.yaml | 28 ++- .../config/expression/anyElementTrue.yaml | 36 ++- generator/config/expression/arrayElemAt.yaml | 27 ++- .../config/expression/arrayToObject.yaml | 86 +++++-- generator/config/expression/asin.yaml | 28 ++- generator/config/expression/asinh.yaml | 18 +- generator/config/expression/atan.yaml | 28 ++- generator/config/expression/atan2.yaml | 28 ++- generator/config/expression/atanh.yaml | 18 +- generator/config/expression/avg.yaml | 45 +++- generator/config/expression/binarySize.yaml | 24 +- generator/config/expression/bitAnd.yaml | 47 +++- generator/config/expression/bitNot.yaml | 22 +- generator/config/expression/bitOr.yaml | 47 +++- generator/config/expression/bitXor.yaml | 24 +- generator/config/expression/bsonSize.yaml | 159 ++++++++++++- generator/config/expression/case.yaml | 2 +- generator/config/expression/ceil.yaml | 18 +- generator/config/expression/cmp.yaml | 26 ++- generator/config/expression/concat.yaml | 11 +- generator/config/expression/concatArrays.yaml | 30 ++- generator/config/expression/cond.yaml | 22 +- generator/config/expression/convert.yaml | 59 +++-- generator/config/expression/cos.yaml | 24 +- generator/config/expression/cosh.yaml | 18 +- generator/config/expression/dateAdd.yaml | 100 +++++--- generator/config/expression/dateDiff.yaml | 110 ++++++--- .../config/expression/dateFromParts.yaml | 9 +- .../config/expression/dateFromString.yaml | 79 +++++-- generator/config/expression/dateSubtract.yaml | 110 ++++++--- generator/config/expression/dateToParts.yaml | 36 ++- generator/config/expression/dateToString.yaml | 46 +++- generator/config/expression/dateTrunc.yaml | 76 +++++- generator/config/expression/dayOfMonth.yaml | 32 ++- generator/config/expression/dayOfWeek.yaml | 32 ++- generator/config/expression/dayOfYear.yaml | 32 ++- .../config/expression/degreesToRadians.yaml | 26 ++- generator/config/expression/divide.yaml | 26 ++- generator/config/expression/eq.yaml | 26 ++- generator/config/expression/exp.yaml | 22 +- generator/config/expression/filter.yaml | 219 +++++++++++++++--- generator/config/expression/first.yaml | 7 +- generator/config/expression/firstN.yaml | 25 +- generator/config/expression/floor.yaml | 8 +- generator/config/expression/function.yaml | 24 +- generator/config/expression/getField.yaml | 26 +-- generator/config/expression/gt.yaml | 10 +- generator/config/expression/gte.yaml | 8 +- generator/config/expression/hour.yaml | 10 +- generator/config/expression/ifNull.yaml | 20 +- generator/config/expression/in.yaml | 12 +- generator/config/expression/indexOfArray.yaml | 8 +- generator/config/expression/indexOfBytes.yaml | 10 +- generator/config/expression/indexOfCP.yaml | 10 +- generator/config/expression/isArray.yaml | 17 +- generator/config/expression/isNumber.yaml | 42 ++-- generator/config/expression/isoDayOfWeek.yaml | 12 +- generator/config/expression/isoWeek.yaml | 12 +- generator/config/expression/isoWeekYear.yaml | 10 +- generator/config/expression/last.yaml | 6 +- generator/config/expression/lastN.yaml | 17 +- generator/config/expression/let.yaml | 18 +- generator/config/expression/literal.yaml | 2 +- generator/config/expression/ln.yaml | 12 +- generator/config/expression/log.yaml | 8 +- generator/config/expression/log10.yaml | 8 +- generator/config/expression/lt.yaml | 8 +- generator/config/expression/lte.yaml | 8 +- generator/config/expression/ltrim.yaml | 8 +- generator/config/expression/map.yaml | 36 ++- generator/config/expression/max.yaml | 17 +- generator/config/expression/maxN.yaml | 10 +- generator/config/expression/median.yaml | 16 +- generator/config/expression/mergeObjects.yaml | 18 +- generator/config/expression/meta.yaml | 18 +- generator/config/expression/millisecond.yaml | 10 +- generator/config/expression/min.yaml | 17 +- generator/config/expression/minN.yaml | 10 +- generator/config/expression/minute.yaml | 10 +- generator/config/expression/mod.yaml | 10 +- generator/config/expression/month.yaml | 10 +- generator/config/expression/multiply.yaml | 10 +- generator/config/expression/ne.yaml | 8 +- generator/config/expression/not.yaml | 8 +- .../config/expression/objectToArray.yaml | 23 +- generator/config/expression/or.yaml | 10 +- generator/config/expression/percentile.yaml | 23 +- generator/config/expression/pow.yaml | 11 +- .../config/expression/radiansToDegrees.yaml | 12 +- generator/config/expression/rand.yaml | 16 +- generator/config/expression/range.yaml | 10 +- generator/config/expression/reduce.yaml | 65 +++--- generator/config/expression/regexFind.yaml | 39 ++-- generator/config/expression/regexFindAll.yaml | 69 +++--- generator/config/expression/regexMatch.yaml | 53 +++-- generator/config/expression/replaceAll.yaml | 12 +- generator/config/expression/replaceOne.yaml | 12 +- generator/config/expression/reverseArray.yaml | 8 +- generator/config/expression/round.yaml | 12 +- generator/config/expression/rtrim.yaml | 8 +- generator/config/expression/second.yaml | 10 +- .../config/expression/setDifference.yaml | 10 +- generator/config/expression/setEquals.yaml | 10 +- generator/config/expression/setField.yaml | 66 +++--- .../config/expression/setIntersection.yaml | 19 +- generator/config/expression/setIsSubset.yaml | 11 +- generator/config/expression/setUnion.yaml | 10 +- generator/config/expression/sin.yaml | 10 +- generator/config/expression/sinh.yaml | 8 +- generator/config/expression/size.yaml | 14 +- generator/config/expression/slice.yaml | 10 +- generator/config/expression/sortArray.yaml | 39 ++-- generator/config/expression/split.yaml | 20 +- generator/config/expression/sqrt.yaml | 14 +- generator/config/expression/stdDevPop.yaml | 11 +- generator/config/expression/stdDevSamp.yaml | 2 +- generator/config/expression/strLenBytes.yaml | 8 +- generator/config/expression/strLenCP.yaml | 8 +- generator/config/expression/strcasecmp.yaml | 10 +- generator/config/expression/substr.yaml | 10 +- generator/config/expression/substrBytes.yaml | 18 +- generator/config/expression/substrCP.yaml | 18 +- generator/config/expression/subtract.yaml | 26 +-- generator/config/expression/sum.yaml | 17 +- generator/config/expression/switch.yaml | 32 +-- generator/config/expression/tan.yaml | 10 +- generator/config/expression/tanh.yaml | 8 +- generator/config/expression/toBool.yaml | 12 +- generator/config/expression/toDate.yaml | 8 +- generator/config/expression/toDecimal.yaml | 8 +- generator/config/expression/toDouble.yaml | 8 +- .../config/expression/toHashedIndexKey.yaml | 42 ++-- generator/config/expression/toInt.yaml | 8 +- generator/config/expression/toLong.yaml | 8 +- generator/config/expression/toLower.yaml | 10 +- generator/config/expression/toObjectId.yaml | 8 +- generator/config/expression/toString.yaml | 8 +- generator/config/expression/toUpper.yaml | 10 +- generator/config/expression/trim.yaml | 8 +- generator/config/expression/trunc.yaml | 8 +- generator/config/expression/tsIncrement.yaml | 14 +- generator/config/expression/tsSecond.yaml | 14 +- generator/config/expression/type.yaml | 8 +- generator/config/expression/unsetField.yaml | 32 ++- generator/config/expression/week.yaml | 10 +- generator/config/expression/year.yaml | 10 +- generator/config/expression/zip.yaml | 30 +-- generator/config/query/all.yaml | 20 +- generator/config/query/and.yaml | 10 +- generator/config/query/bitsAllClear.yaml | 33 +-- generator/config/query/bitsAllSet.yaml | 37 +-- generator/config/query/bitsAnyClear.yaml | 37 +-- generator/config/query/bitsAnySet.yaml | 37 +-- generator/config/query/box.yaml | 2 +- generator/config/query/center.yaml | 2 +- generator/config/query/centerSphere.yaml | 2 +- generator/config/query/comment.yaml | 12 +- generator/config/query/elemMatch.yaml | 22 +- generator/config/query/eq.yaml | 39 ++-- generator/config/query/exists.yaml | 16 +- generator/config/query/expr.yaml | 20 +- generator/config/query/geoIntersects.yaml | 58 +++-- generator/config/query/geoWithin.yaml | 58 +++-- generator/config/query/geometry.yaml | 2 +- generator/config/query/gt.yaml | 6 +- generator/config/query/gte.yaml | 6 +- generator/config/query/in.yaml | 24 +- generator/config/query/jsonSchema.yaml | 26 +-- generator/config/query/lt.yaml | 6 +- generator/config/query/lte.yaml | 6 +- generator/config/query/maxDistance.yaml | 2 +- generator/config/query/minDistance.yaml | 2 +- generator/config/query/mod.yaml | 26 ++- generator/config/query/ne.yaml | 6 +- generator/config/query/near.yaml | 8 +- generator/config/query/nearSphere.yaml | 12 +- generator/config/query/nin.yaml | 19 +- generator/config/query/nor.yaml | 14 +- generator/config/query/not.yaml | 14 +- generator/config/query/or.yaml | 13 +- generator/config/query/polygon.yaml | 2 +- generator/config/query/rand.yaml | 6 +- generator/config/query/regex.yaml | 17 +- generator/config/query/sampleRate.yaml | 8 +- generator/config/query/size.yaml | 6 +- generator/config/query/text.yaml | 52 ++--- generator/config/query/type.yaml | 66 +++--- generator/config/query/where.yaml | 11 +- generator/config/schema.json | 190 +++++++++++++-- generator/config/search/autocomplete.yaml | 69 +++--- generator/config/search/compound.yaml | 86 ++++--- generator/config/search/embeddedDocument.yaml | 77 +++--- generator/config/search/equals.yaml | 64 +++-- generator/config/search/exists.yaml | 30 ++- generator/config/search/facet.yaml | 22 +- generator/config/search/geoShape.yaml | 138 +++++++---- generator/config/search/geoWithin.yaml | 58 +++-- generator/config/search/in.yaml | 44 ++-- generator/config/search/moreLikeThis.yaml | 50 ++-- generator/config/search/near.yaml | 51 ++-- generator/config/search/phrase.yaml | 51 ++-- generator/config/search/queryString.yaml | 17 +- generator/config/search/range.yaml | 52 ++--- generator/config/search/regex.yaml | 8 +- generator/config/search/text.yaml | 100 ++++---- generator/config/search/wildcard.yaml | 15 +- generator/config/stage/addFields.yaml | 40 ++-- generator/config/stage/bucket.yaml | 62 +++-- generator/config/stage/bucketAuto.yaml | 10 +- generator/config/stage/changeStream.yaml | 6 +- .../stage/changeStreamSplitLargeEvent.yaml | 6 +- generator/config/stage/collStats.yaml | 22 +- generator/config/stage/count.yaml | 22 +- generator/config/stage/currentOp.yaml | 12 +- generator/config/stage/densify.yaml | 28 +-- generator/config/stage/documents.yaml | 33 +-- generator/config/stage/facet.yaml | 29 +-- generator/config/stage/fill.yaml | 40 ++-- generator/config/stage/geoNear.yaml | 66 +++--- generator/config/stage/graphLookup.yaml | 52 ++--- generator/config/stage/group.yaml | 72 +++--- generator/config/stage/indexStats.yaml | 6 +- generator/config/stage/limit.yaml | 6 +- generator/config/stage/listLocalSessions.yaml | 18 +- .../config/stage/listSampledQueries.yaml | 13 +- generator/config/stage/listSearchIndexes.yaml | 18 +- generator/config/stage/listSessions.yaml | 19 +- generator/config/stage/lookup.yaml | 96 ++++---- generator/config/stage/match.yaml | 14 +- generator/config/stage/merge.yaml | 118 +++++----- generator/config/stage/out.yaml | 27 +-- generator/config/stage/planCacheStats.yaml | 12 +- generator/config/stage/project.yaml | 60 ++--- generator/config/stage/redact.yaml | 28 +-- generator/config/stage/replaceRoot.yaml | 32 ++- generator/config/stage/replaceWith.yaml | 42 ++-- generator/config/stage/sample.yaml | 6 +- generator/config/stage/search.yaml | 104 ++++----- generator/config/stage/searchMeta.yaml | 106 ++++----- generator/config/stage/set.yaml | 45 ++-- generator/config/stage/setWindowFields.yaml | 99 ++++---- .../config/stage/shardedDataDistribution.yaml | 6 +- generator/config/stage/skip.yaml | 6 +- generator/config/stage/sort.yaml | 14 +- generator/config/stage/sortByCount.yaml | 12 +- generator/config/stage/unionWith.yaml | 30 ++- generator/config/stage/unset.yaml | 30 ++- generator/config/stage/unwind.yaml | 52 ++--- generator/config/stage/vectorSearch.yaml | 52 +++-- 288 files changed, 6092 insertions(+), 3302 deletions(-) diff --git a/generator/config/accumulator/accumulator.yaml b/generator/config/accumulator/accumulator.yaml index 9cfdb6b53..a95dfe406 100644 --- a/generator/config/accumulator/accumulator.yaml +++ b/generator/config/accumulator/accumulator.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $accumulator -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/ type: - accumulator encode: object @@ -52,15 +52,14 @@ arguments: - string description: | The language used in the $accumulator code. - tests: - - name: 'Use $accumulator to Implement the $avg Operator' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#use--accumulator-to-implement-the--avg-operator' + name: Use $accumulator to Implement the $avg Operator + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#use--accumulator-to-implement-the--avg-operator pipeline: - $group: - _id: '$author' + _id: $author avgCopies: $accumulator: init: @@ -73,7 +72,8 @@ tests: function(state, numCopies) { return { count: state.count + 1, sum: state.sum + numCopies } } - accumulateArgs: [ "$copies" ] + accumulateArgs: + - $copies merge: $code: |- function(state1, state2) { @@ -87,16 +87,33 @@ tests: function(state) { return (state.sum / state.count) } - lang: 'js' - + lang: js + schema: + books: + _id: + types: + - + bsonType: Number + title: + types: + - + bsonType: String + author: + types: + - + bsonType: String + copies: + types: + - + bsonType: Number - - name: 'Use initArgs to Vary the Initial State by Group' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#use-initargs-to-vary-the-initial-state-by-group' + name: Use initArgs to Vary the Initial State by Group + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#use-initargs-to-vary-the-initial-state-by-group pipeline: - $group: _id: - city: '$city' + city: $city restaurants: $accumulator: init: @@ -105,8 +122,8 @@ tests: return { max: city === userProfileCity ? 3 : 1, restaurants: [] } } initArgs: - - '$city' - - 'Bettles' + - $city + - Bettles accumulate: $code: |- function(state, restaurantName) { @@ -115,7 +132,8 @@ tests: } return state; } - accumulateArgs: ['$name'] + accumulateArgs: + - $name merge: $code: |- function(state1, state2) { @@ -129,4 +147,22 @@ tests: function(state) { return state.restaurants } - lang: 'js' + lang: js + schema: + restaurants: + _id: + types: + - + bsonType: Number + name: + types: + - + bsonType: String + city: + types: + - + bsonType: String + cuisine: + types: + - + bsonType: String diff --git a/generator/config/accumulator/addToSet.yaml b/generator/config/accumulator/addToSet.yaml index 9566899eb..170d13af2 100644 --- a/generator/config/accumulator/addToSet.yaml +++ b/generator/config/accumulator/addToSet.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $addToSet -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/ type: - accumulator - window @@ -13,35 +13,83 @@ arguments: name: expression type: - expression - tests: - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--group-stage' + name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--group-stage pipeline: - - $group: + - + $group: + _id: + day: + $dayOfYear: + date: $date + year: + $year: + date: $date + itemsSold: + $addToSet: $item + schema: + sales: _id: - day: - $dayOfYear: - date: '$date' - year: - $year: - date: '$date' - itemsSold: - $addToSet: '$item' + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--setwindowfields-stage' + name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--setwindowfields-stage pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: cakeTypesForState: - $addToSet: '$type' + $addToSet: $type window: documents: - - 'unbounded' - - 'current' + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/avg.yaml b/generator/config/accumulator/avg.yaml index 3777bbf98..8d426a36f 100644 --- a/generator/config/accumulator/avg.yaml +++ b/generator/config/accumulator/avg.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $avg -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/ type: - accumulator - window @@ -15,31 +15,80 @@ arguments: - resolvesToNumber tests: - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--group-stage' + name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--group-stage pipeline: - - $group: - _id: '$item' + - + $group: + _id: $item avgAmount: $avg: $multiply: - - '$price' - - '$quantity' + - $price + - $quantity avgQuantity: - $avg: '$quantity' + $avg: $quantity + schema: + sales: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--setwindowfields-stage' + name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--setwindowfields-stage pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: averageQuantityForState: - $avg: '$quantity' + $avg: $quantity window: documents: - - 'unbounded' - - 'current' + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/bottom.yaml b/generator/config/accumulator/bottom.yaml index 1e363d193..15138b741 100644 --- a/generator/config/accumulator/bottom.yaml +++ b/generator/config/accumulator/bottom.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bottom -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/ type: - accumulator - window @@ -23,33 +23,61 @@ arguments: Represents the output for each element in the group and can be any expression. tests: - - name: 'Find the Bottom Score' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/#find-the-bottom-score' + name: Find the Bottom Score + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/#find-the-bottom-score pipeline: - $match: - gameId: 'G1' + gameId: G1 - $group: - _id: '$gameId' + _id: $gameId playerId: $bottom: output: - - '$playerId' - - '$score' + - $playerId + - $score sortBy: score: -1 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Finding the Bottom Score Across Multiple Games' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/#finding-the-bottom-score-across-multiple-games' + name: Finding the Bottom Score Across Multiple Games + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/#finding-the-bottom-score-across-multiple-games pipeline: - $group: - _id: '$gameId' + _id: $gameId playerId: $bottom: output: - - '$playerId' - - '$score' + - $playerId + - $score sortBy: score: -1 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/bottomN.yaml b/generator/config/accumulator/bottomN.yaml index 355d8e09a..aedb55c6e 100644 --- a/generator/config/accumulator/bottomN.yaml +++ b/generator/config/accumulator/bottomN.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bottomN -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/ type: - accumulator - window @@ -30,56 +30,98 @@ arguments: Represents the output for each element in the group and can be any expression. tests: - - name: 'Find the Three Lowest Scores' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/#find-the-three-lowest-scores' + name: Find the Three Lowest Scores + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/#find-the-three-lowest-scores pipeline: - $match: - gameId: 'G1' + gameId: G1 - $group: - _id: '$gameId' + _id: $gameId playerId: $bottomN: output: - - '$playerId' - - '$score' + - $playerId + - $score sortBy: score: -1 - n: 3 + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Finding the Three Lowest Score Documents Across Multiple Games' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/#finding-the-three-lowest-score-documents-across-multiple-games' + name: Finding the Three Lowest Score Documents Across Multiple Games + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/#finding-the-three-lowest-score-documents-across-multiple-games pipeline: - $group: - _id: '$gameId' + _id: $gameId playerId: $bottomN: output: - - '$playerId' - - '$score' + - $playerId + - $score sortBy: score: -1 - n: 3 + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Computing n Based on the Group Key for $group' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/#computing-n-based-on-the-group-key-for--group' + name: Computing n Based on the Group Key for $group + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/#computing-n-based-on-the-group-key-for--group pipeline: - $group: _id: - gameId: '$gameId' + gameId: $gameId gamescores: $bottomN: - output: '$score' - n: + output: $score + 'n': $cond: if: $eq: - - '$gameId' - - 'G2' + - $gameId + - G2 then: 1 else: 3 sortBy: score: -1 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/count.yaml b/generator/config/accumulator/count.yaml index d9819056d..c525fde0d 100644 --- a/generator/config/accumulator/count.yaml +++ b/generator/config/accumulator/count.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $count -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/count-accumulator/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/count-accumulator/ type: - accumulator - window @@ -11,21 +11,47 @@ description: | New in MongoDB 5.0. tests: - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/count-accumulator/#use-in--group-stage' + name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/count-accumulator/#use-in--group-stage pipeline: - $group: - _id: '$state' + _id: $state countNumberOfDocumentsForState: $count: {} + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/count-accumulator/#use-in--setwindowfields-stage' + name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/count-accumulator/#use-in--setwindowfields-stage pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: @@ -33,5 +59,31 @@ tests: $count: {} window: documents: - - 'unbounded' - - 'current' + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/covariancePop.yaml b/generator/config/accumulator/covariancePop.yaml index b43a24022..e059003f4 100644 --- a/generator/config/accumulator/covariancePop.yaml +++ b/generator/config/accumulator/covariancePop.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $covariancePop -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/covariancePop/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/covariancePop/ type: - window encode: array @@ -18,24 +18,48 @@ arguments: - resolvesToNumber tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/covariancePop/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/covariancePop/#example pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: covariancePopForState: $covariancePop: - - # Example uses the short form, the builder always generates the verbose form - # $year: '$orderDate' $year: - date: '$orderDate' - - '$quantity' + date: $orderDate + - $quantity window: documents: - - 'unbounded' - - 'current' + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/covarianceSamp.yaml b/generator/config/accumulator/covarianceSamp.yaml index b6cc529af..089e53e6f 100644 --- a/generator/config/accumulator/covarianceSamp.yaml +++ b/generator/config/accumulator/covarianceSamp.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $covarianceSamp -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/covarianceSamp/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/covarianceSamp/ type: - window encode: array @@ -18,24 +18,48 @@ arguments: - resolvesToNumber tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/covarianceSamp/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/covarianceSamp/#example pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: covarianceSampForState: $covarianceSamp: - - # Example uses the short form, the builder always generates the verbose form - # $year: '$orderDate' $year: - date: '$orderDate' - - '$quantity' + date: $orderDate + - $quantity window: documents: - - 'unbounded' - - 'current' + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/denseRank.yaml b/generator/config/accumulator/denseRank.yaml index 0c50dd901..dab4b8f08 100644 --- a/generator/config/accumulator/denseRank.yaml +++ b/generator/config/accumulator/denseRank.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $denseRank -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/ type: - window encode: object @@ -9,26 +9,78 @@ description: | New in MongoDB 5.0. tests: - - name: 'Dense Rank Partitions by an Integer Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/#dense-rank-partitions-by-an-integer-field' + name: Dense Rank Partitions by an Integer Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/#dense-rank-partitions-by-an-integer-field pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: quantity: -1 output: denseRankQuantityForState: $denseRank: {} + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number - - name: 'Dense Rank Partitions by a Date Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/#dense-rank-partitions-by-a-date-field' + name: Dense Rank Partitions by a Date Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/#dense-rank-partitions-by-a-date-field pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: denseRankOrderDateForState: $denseRank: {} + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/derivative.yaml b/generator/config/accumulator/derivative.yaml index 5745e9380..b5a06e13b 100644 --- a/generator/config/accumulator/derivative.yaml +++ b/generator/config/accumulator/derivative.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $derivative -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/derivative/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/derivative/ type: - window encode: object @@ -23,25 +23,39 @@ arguments: If the sortBy field is not a date, you must omit a unit. If you specify a unit, you must specify a date in the sortBy field. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/derivative/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/derivative/#example pipeline: - $setWindowFields: - partitionBy: '$truckID' + partitionBy: $truckID sortBy: timeStamp: 1 output: truckAverageSpeed: $derivative: - input: '$miles' - unit: 'hour' + input: $miles + unit: hour window: range: - -30 - 0 - unit: 'second' + unit: second - $match: truckAverageSpeed: $gt: 50 + schema: + deliveryFleet: + truckID: + types: + - + bsonType: String + timeStamp: + types: + - + bsonType: Date + miles: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/documentNumber.yaml b/generator/config/accumulator/documentNumber.yaml index b810ccd44..3fd086191 100644 --- a/generator/config/accumulator/documentNumber.yaml +++ b/generator/config/accumulator/documentNumber.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $documentNumber -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/documentNumber/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/documentNumber/ type: - window encode: object @@ -9,14 +9,40 @@ description: | New in MongoDB 5.0. tests: - - name: 'Document Number for Each State' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/documentNumber/#document-number-for-each-state' + name: Document Number for Each State + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/documentNumber/#document-number-for-each-state pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: quantity: -1 output: documentNumberForState: $documentNumber: {} + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/expMovingAvg.yaml b/generator/config/accumulator/expMovingAvg.yaml index 3009dd115..2f3ed8041 100644 --- a/generator/config/accumulator/expMovingAvg.yaml +++ b/generator/config/accumulator/expMovingAvg.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $expMovingAvg -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/expMovingAvg/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/expMovingAvg/ type: - window encode: object @@ -31,30 +31,58 @@ arguments: You must specify either N or alpha. You cannot specify both. tests: - - name: 'Exponential Moving Average Using N' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/expMovingAvg/#exponential-moving-average-using-n' + name: Exponential Moving Average Using N + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/expMovingAvg/#exponential-moving-average-using-n pipeline: - $setWindowFields: - partitionBy: '$stock' + partitionBy: $stock sortBy: date: 1 output: expMovingAvgForStock: $expMovingAvg: - input: '$price' - N: 2 + input: $price + 'N': 2 + schema: + stockPrices: + stock: + types: + - + bsonType: String + date: + types: + - + bsonType: Date + price: + types: + - + bsonType: Number - - name: 'Exponential Moving Average Using alpha' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/expMovingAvg/#exponential-moving-average-using-alpha' + name: Exponential Moving Average Using alpha + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/expMovingAvg/#exponential-moving-average-using-alpha pipeline: - $setWindowFields: - partitionBy: '$stock' + partitionBy: $stock sortBy: date: 1 output: expMovingAvgForStock: $expMovingAvg: - input: '$price' + input: $price alpha: 0.75 + schema: + stockPrices: + stock: + types: + - + bsonType: String + date: + types: + - + bsonType: Date + price: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/first.yaml b/generator/config/accumulator/first.yaml index d82f831a0..613d412f2 100644 --- a/generator/config/accumulator/first.yaml +++ b/generator/config/accumulator/first.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $first -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/ type: - accumulator - window @@ -15,8 +15,8 @@ arguments: - expression tests: - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/#use-in--group-stage' + name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/#use-in--group-stage pipeline: - $sort: @@ -24,22 +24,70 @@ tests: date: 1 - $group: - _id: '$item' + _id: $item firstSale: - $first: '$date' + $first: $date + schema: + sales: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/#use-in--setwindowfields-stage' + name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/#use-in--setwindowfields-stage pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: firstOrderTypeForState: - $first: '$type' + $first: $type window: documents: - - 'unbounded' - - 'current' + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/firstN.yaml b/generator/config/accumulator/firstN.yaml index cb7a6e96c..9d2f56452 100644 --- a/generator/config/accumulator/firstN.yaml +++ b/generator/config/accumulator/firstN.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $firstN -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/ type: - accumulator - window @@ -24,99 +24,122 @@ arguments: A positive integral expression that is either a constant or depends on the _id value for $group. tests: - - name: 'Null and Missing Values' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#null-and-missing-values' - pipeline: - - - $documents: - - - playerId: 'PlayerA' - gameId: 'G1' - score: 1 - - - playerId: 'PlayerB' - gameId: 'G1' - score: 2 - - - playerId: 'PlayerC' - gameId: 'G1' - score: 3 - - - playerId: 'PlayerD' - gameId: 'G1' - - - playerId: 'PlayerE' - gameId: 'G1' - score: ~ - - - $group: - _id: '$gameId' - firstFiveScores: - $firstN: - input: '$score' - n: 5 - - - name: 'Find the First Three Player Scores for a Single Game' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#find-the-first-three-player-scores-for-a-single-game' + name: Find the First Three Player Scores for a Single Game + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#find-the-first-three-player-scores-for-a-single-game pipeline: - $match: - gameId: 'G1' + gameId: G1 - $group: - _id: '$gameId' + _id: $gameId firstThreeScores: $firstN: input: - - '$playerId' - - '$score' - n: 3 + - $playerId + - $score + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Finding the First Three Player Scores Across Multiple Games' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#finding-the-first-three-player-scores-across-multiple-games' + name: Finding the First Three Player Scores Across Multiple Games + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#finding-the-first-three-player-scores-across-multiple-games pipeline: - $group: - _id: '$gameId' + _id: $gameId playerId: $firstN: input: - - '$playerId' - - '$score' - n: 3 + - $playerId + - $score + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Using $sort With $firstN' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#using--sort-with--firstn' + name: Using $sort With $firstN + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#using--sort-with--firstn pipeline: - $sort: score: -1 - $group: - _id: '$gameId' + _id: $gameId playerId: $firstN: input: - - '$playerId' - - '$score' - n: 3 + - $playerId + - $score + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Computing n Based on the Group Key for $group' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#computing-n-based-on-the-group-key-for--group' + name: Computing n Based on the Group Key for $group + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#computing-n-based-on-the-group-key-for--group pipeline: - $group: _id: - gameId: '$gameId' + gameId: $gameId gamescores: $firstN: - input: '$score' - n: + input: $score + 'n': $cond: if: $eq: - - '$gameId' - - 'G2' + - $gameId + - G2 then: 1 else: 3 - + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/integral.yaml b/generator/config/accumulator/integral.yaml index efc803597..46e1de4f1 100644 --- a/generator/config/accumulator/integral.yaml +++ b/generator/config/accumulator/integral.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $integral -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/integral/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/integral/ type: - window encode: object @@ -23,21 +23,35 @@ arguments: If the sortBy field is not a date, you must omit a unit. If you specify a unit, you must specify a date in the sortBy field. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/integral/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/integral/#example pipeline: - $setWindowFields: - partitionBy: '$powerMeterID' + partitionBy: $powerMeterID sortBy: timeStamp: 1 output: powerMeterKilowattHours: $integral: - input: '$kilowatts' - unit: 'hour' + input: $kilowatts + unit: hour window: range: - - 'unbounded' - - 'current' - unit: 'hour' + - unbounded + - current + unit: hour + schema: + powerConsumption: + powerMeterID: + types: + - + bsonType: String + timeStamp: + types: + - + bsonType: Date + kilowatts: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/last.yaml b/generator/config/accumulator/last.yaml index 969c05524..671c4dab7 100644 --- a/generator/config/accumulator/last.yaml +++ b/generator/config/accumulator/last.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $last -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/ type: - accumulator - window @@ -15,8 +15,8 @@ arguments: - expression tests: - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/' + name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/ pipeline: - $sort: @@ -24,22 +24,49 @@ tests: date: 1 - $group: - _id: '$item' + _id: $item lastSalesDate: - $last: '$date' + $last: $date + schema: '// TODO: No schema found in docs' - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/#use-in--setwindowfields-stage' + name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/#use-in--setwindowfields-stage pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: lastOrderTypeForState: - $last: '$type' + $last: $type window: documents: - - 'current' - - 'unbounded' + - current + - unbounded + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/lastN.yaml b/generator/config/accumulator/lastN.yaml index 13c9b72bd..2fc75969a 100644 --- a/generator/config/accumulator/lastN.yaml +++ b/generator/config/accumulator/lastN.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $lastN -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/ type: - accumulator - window @@ -24,66 +24,122 @@ arguments: An expression that resolves to a positive integer. The integer specifies the number of array elements that $firstN returns. tests: - - name: 'Find the Last Three Player Scores for a Single Game' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#find-the-last-three-player-scores-for-a-single-game' + name: Find the Last Three Player Scores for a Single Game + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#find-the-last-three-player-scores-for-a-single-game pipeline: - $match: - gameId: 'G1' + gameId: G1 - $group: - _id: '$gameId' + _id: $gameId lastThreeScores: $lastN: input: - - '$playerId' - - '$score' - n: 3 + - $playerId + - $score + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Finding the Last Three Player Scores Across Multiple Games' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#finding-the-last-three-player-scores-across-multiple-games' + name: Finding the Last Three Player Scores Across Multiple Games + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#finding-the-last-three-player-scores-across-multiple-games pipeline: - $group: - _id: '$gameId' + _id: $gameId playerId: $lastN: input: - - '$playerId' - - '$score' - n: 3 + - $playerId + - $score + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Using $sort With $lastN' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#using--sort-with--lastn' + name: Using $sort With $lastN + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#using--sort-with--lastn pipeline: - $sort: score: -1 - $group: - _id: '$gameId' + _id: $gameId playerId: $lastN: input: - - '$playerId' - - '$score' - n: 3 + - $playerId + - $score + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Computing n Based on the Group Key for $group' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#computing-n-based-on-the-group-key-for--group' + name: Computing n Based on the Group Key for $group + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#computing-n-based-on-the-group-key-for--group pipeline: - $group: _id: - gameId: '$gameId' + gameId: $gameId gamescores: $lastN: - input: '$score' - n: + input: $score + 'n': $cond: if: $eq: - - '$gameId' - - 'G2' + - $gameId + - G2 then: 1 else: 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/linearFill.yaml b/generator/config/accumulator/linearFill.yaml index 034e6ab9e..f2a644dc7 100644 --- a/generator/config/accumulator/linearFill.yaml +++ b/generator/config/accumulator/linearFill.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $linearFill -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearFill/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearFill/ type: - window encode: single @@ -15,8 +15,8 @@ arguments: - resolvesToNumber tests: - - name: 'Fill Missing Values with Linear Interpolation' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearFill/#fill-missing-values-with-linear-interpolation' + name: Fill Missing Values with Linear Interpolation + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearFill/#fill-missing-values-with-linear-interpolation pipeline: - $setWindowFields: @@ -24,10 +24,20 @@ tests: time: 1 output: price: - $linearFill: '$price' + $linearFill: $price + schema: + stock: + time: + types: + - + bsonType: Date + price: + types: + - + bsonType: Number - - name: 'Use Multiple Fill Methods in a Single Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearFill/#use-multiple-fill-methods-in-a-single-stage' + name: Use Multiple Fill Methods in a Single Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearFill/#use-multiple-fill-methods-in-a-single-stage pipeline: - $setWindowFields: @@ -35,6 +45,16 @@ tests: time: 1 output: linearFillPrice: - $linearFill: '$price' + $linearFill: $price locfPrice: - $locf: '$price' + $locf: $price + schema: + stock: + time: + types: + - + bsonType: Date + price: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/locf.yaml b/generator/config/accumulator/locf.yaml index 63979bca4..c01d9486e 100644 --- a/generator/config/accumulator/locf.yaml +++ b/generator/config/accumulator/locf.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $locf -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/locf/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/locf/ type: - window encode: single @@ -15,8 +15,8 @@ arguments: - expression tests: - - name: 'Fill Missing Values with the Last Observed Value' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/locf/#fill-missing-values-with-the-last-observed-value' + name: Fill Missing Values with the Last Observed Value + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/locf/#fill-missing-values-with-the-last-observed-value pipeline: - $setWindowFields: @@ -24,4 +24,14 @@ tests: time: 1 output: price: - $locf: '$price' + $locf: $price + schema: + stock: + time: + types: + - + bsonType: Date + price: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/max.yaml b/generator/config/accumulator/max.yaml index 165cefc43..d1dda0f5e 100644 --- a/generator/config/accumulator/max.yaml +++ b/generator/config/accumulator/max.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $max -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/ type: - accumulator - window @@ -15,32 +15,80 @@ arguments: - expression tests: - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#use-in--group-stage' + name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#use-in--group-stage pipeline: - $group: - _id: '$item' + _id: $item maxTotalAmount: $max: $multiply: - - '$price' - - '$quantity' + - $price + - $quantity maxQuantity: - $max: '$quantity' + $max: $quantity + schema: + sales: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#use-in--setwindowfields-stage' + name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#use-in--setwindowfields-stage pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: maximumQuantityForState: - $max: '$quantity' + $max: $quantity window: documents: - - 'unbounded' - - 'current' + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/maxN.yaml b/generator/config/accumulator/maxN.yaml index 4014782a8..25ab9cfae 100644 --- a/generator/config/accumulator/maxN.yaml +++ b/generator/config/accumulator/maxN.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $maxN -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/ type: - accumulator - window @@ -22,52 +22,94 @@ arguments: An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. tests: - - name: 'Find the Maximum Three Scores for a Single Game' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/#find-the-maximum-three-scores-for-a-single-game' + name: Find the Maximum Three Scores for a Single Game + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/#find-the-maximum-three-scores-for-a-single-game pipeline: - $match: - gameId: 'G1' + gameId: G1 - $group: - _id: '$gameId' + _id: $gameId maxThreeScores: $maxN: input: - - '$score' - - '$playerId' - n: 3 + - $score + - $playerId + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Finding the Maximum Three Scores Across Multiple Games' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/#finding-the-maximum-three-scores-across-multiple-games' + name: Finding the Maximum Three Scores Across Multiple Games + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/#finding-the-maximum-three-scores-across-multiple-games pipeline: - $group: - _id: '$gameId' + _id: $gameId maxScores: $maxN: input: - - '$score' - - '$playerId' - n: 3 + - $score + - $playerId + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Computing n Based on the Group Key for $group' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/#computing-n-based-on-the-group-key-for--group' + name: Computing n Based on the Group Key for $group + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/#computing-n-based-on-the-group-key-for--group pipeline: - $group: _id: - gameId: '$gameId' + gameId: $gameId gamescores: $maxN: input: - - '$score' - - '$playerId' - n: + - $score + - $playerId + 'n': $cond: if: $eq: - - '$gameId' - - 'G2' + - $gameId + - G2 then: 1 else: 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/median.yaml b/generator/config/accumulator/median.yaml index e743c6982..c3b93800a 100644 --- a/generator/config/accumulator/median.yaml +++ b/generator/config/accumulator/median.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $median -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/ type: - accumulator - window @@ -27,19 +27,37 @@ arguments: The method that mongod uses to calculate the 50th percentile value. The method must be 'approximate'. tests: - - name: 'Use $median as an Accumulator' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/#use-operatorname-as-an-accumulator' + name: Use $median as an Accumulator + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/#use-operatorname-as-an-accumulator pipeline: - $group: - _id: ~ + _id: null test01_median: $median: - input: '$test01' - method: 'approximate' + input: $test01 + method: approximate + schema: + testScores: + studentId: + types: + - + bsonType: String + test01: + types: + - + bsonType: Number + test02: + types: + - + bsonType: Number + test03: + types: + - + bsonType: Number - - name: 'Use $median in a $setWindowField Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/#use-operatorname-in-a--setwindowfield-stage' + name: Use $median in a $setWindowField Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/#use-operatorname-in-a--setwindowfield-stage pipeline: - $setWindowFields: @@ -48,8 +66,8 @@ tests: output: test01_median: $median: - input: '$test01' - method: 'approximate' + input: $test01 + method: approximate window: range: - -3 @@ -59,3 +77,21 @@ tests: _id: 0 studentId: 1 test01_median: 1 + schema: + testScores: + studentId: + types: + - + bsonType: String + test01: + types: + - + bsonType: Number + test02: + types: + - + bsonType: Number + test03: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/mergeObjects.yaml b/generator/config/accumulator/mergeObjects.yaml index d68728001..57138ef8f 100644 --- a/generator/config/accumulator/mergeObjects.yaml +++ b/generator/config/accumulator/mergeObjects.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $mergeObjects -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/ type: - accumulator encode: single @@ -15,11 +15,54 @@ arguments: Any valid expression that resolves to a document. tests: - - name: '$mergeObjects as an Accumulator' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/#-mergeobjects-as-an-accumulator' + name: $mergeObjects as an Accumulator + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/#-mergeobjects-as-an-accumulator pipeline: - $group: - _id: '$item' + _id: $item mergedSales: - $mergeObjects: '$quantity' + $mergeObjects: $quantity + schema: + sales: + _id: + types: + - + bsonType: Number + year: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + quantity: + types: + - + bsonType: Document + fields: + 2017Q1: + types: + - + bsonType: Number + 2017Q2: + types: + - + bsonType: Number + 2016Q1: + types: + - + bsonType: Number + 2016Q2: + types: + - + bsonType: Number + 2016Q3: + types: + - + bsonType: Number + 2016Q4: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/min.yaml b/generator/config/accumulator/min.yaml index 226d56ec8..20e05b08b 100644 --- a/generator/config/accumulator/min.yaml +++ b/generator/config/accumulator/min.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $min -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/ type: - accumulator - window @@ -15,27 +15,75 @@ arguments: - expression tests: - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#use-in--group-stage' + name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#use-in--group-stage pipeline: - $group: - _id: '$item' + _id: $item minQuantity: - $min: '$quantity' + $min: $quantity + schema: + sales: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#use-in--setwindowfields-stage' + name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#use-in--setwindowfields-stage pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: minimumQuantityForState: - $min: '$quantity' + $min: $quantity window: documents: - - 'unbounded' - - 'current' + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/minN.yaml b/generator/config/accumulator/minN.yaml index 24719a22a..b51fbcb30 100644 --- a/generator/config/accumulator/minN.yaml +++ b/generator/config/accumulator/minN.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $minN -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/ type: - accumulator - window @@ -22,52 +22,94 @@ arguments: An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. tests: - - name: 'Find the Minimum Three Scores for a Single Game' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/#find-the-minimum-three-scores-for-a-single-game' + name: Find the Minimum Three Scores for a Single Game + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/#find-the-minimum-three-scores-for-a-single-game pipeline: - $match: - gameId: 'G1' + gameId: G1 - $group: - _id: '$gameId' + _id: $gameId minScores: $minN: input: - - '$score' - - '$playerId' - n: 3 + - $score + - $playerId + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Finding the Minimum Three Documents Across Multiple Games' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/#finding-the-minimum-three-documents-across-multiple-games' + name: Finding the Minimum Three Documents Across Multiple Games + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/#finding-the-minimum-three-documents-across-multiple-games pipeline: - $group: - _id: '$gameId' + _id: $gameId minScores: $minN: input: - - '$score' - - '$playerId' - n: 3 + - $score + - $playerId + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Computing n Based on the Group Key for $group' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/#computing-n-based-on-the-group-key-for--group' + name: Computing n Based on the Group Key for $group + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/#computing-n-based-on-the-group-key-for--group pipeline: - $group: _id: - gameId: '$gameId' + gameId: $gameId gamescores: $minN: input: - - '$score' - - '$playerId' - n: + - $score + - $playerId + 'n': $cond: if: $eq: - - '$gameId' - - 'G2' + - $gameId + - G2 then: 1 else: 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/percentile.yaml b/generator/config/accumulator/percentile.yaml index b3c41b0e4..c2c85da18 100644 --- a/generator/config/accumulator/percentile.yaml +++ b/generator/config/accumulator/percentile.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $percentile -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/ type: - accumulator - window @@ -25,7 +25,7 @@ arguments: - name: p type: - - resolvesToArray # of resolvesToNumber + - resolvesToArray description: | $percentile calculates a percentile value for each element in p. The elements represent percentages and must evaluate to numeric values in the range 0.0 to 1.0, inclusive. $percentile returns results in the same order as the elements in p. @@ -37,48 +37,100 @@ arguments: The method that mongod uses to calculate the percentile value. The method must be 'approximate'. tests: - - name: 'Calculate a Single Value as an Accumulator' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/#calculate-a-single-value-as-an-accumulator' + name: Calculate a Single Value as an Accumulator + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/#calculate-a-single-value-as-an-accumulator pipeline: - $group: - _id: ~ + _id: null test01_percentiles: $percentile: - input: '$test01' + input: $test01 p: - 0.95 - method: 'approximate' + method: approximate + schema: + testScores: + studentId: + types: + - + bsonType: String + test01: + types: + - + bsonType: Number + test02: + types: + - + bsonType: Number + test03: + types: + - + bsonType: Number - - name: 'Calculate Multiple Values as an Accumulator' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/#calculate-multiple-values-as-an-accumulator' + name: Calculate Multiple Values as an Accumulator + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/#calculate-multiple-values-as-an-accumulator pipeline: - $group: - _id: ~ + _id: null test01_percentiles: $percentile: - input: '$test01' - p: [0.5, 0.75, 0.9, 0.95] - method: 'approximate' + input: $test01 + p: + - 0.5 + - 0.75 + - 0.9 + - 0.95 + method: approximate test02_percentiles: $percentile: - input: '$test02' - p: [0.5, 0.75, 0.9, 0.95] - method: 'approximate' + input: $test02 + p: + - 0.5 + - 0.75 + - 0.9 + - 0.95 + method: approximate test03_percentiles: $percentile: - input: '$test03' - p: [0.5, 0.75, 0.9, 0.95] - method: 'approximate' + input: $test03 + p: + - 0.5 + - 0.75 + - 0.9 + - 0.95 + method: approximate test03_percent_alt: $percentile: - input: '$test03' - p: [0.9, 0.5, 0.75, 0.95] - method: 'approximate' + input: $test03 + p: + - 0.9 + - 0.5 + - 0.75 + - 0.95 + method: approximate + schema: + testScores: + studentId: + types: + - + bsonType: String + test01: + types: + - + bsonType: Number + test02: + types: + - + bsonType: Number + test03: + types: + - + bsonType: Number - - name: 'Use $percentile in a $setWindowField Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/#use-operatorname-in-a--setwindowfield-stage' + name: Use $percentile in a $setWindowField Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/#use-operatorname-in-a--setwindowfield-stage pipeline: - $setWindowFields: @@ -87,10 +139,10 @@ tests: output: test01_95percentile: $percentile: - input: '$test01' + input: $test01 p: - 0.95 - method: 'approximate' + method: approximate window: range: - -3 @@ -100,3 +152,21 @@ tests: _id: 0 studentId: 1 test01_95percentile: 1 + schema: + testScores: + studentId: + types: + - + bsonType: String + test01: + types: + - + bsonType: Number + test02: + types: + - + bsonType: Number + test03: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/push.yaml b/generator/config/accumulator/push.yaml index 3fc367c59..20b4f1aee 100644 --- a/generator/config/accumulator/push.yaml +++ b/generator/config/accumulator/push.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $push -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/ type: - accumulator - window @@ -15,8 +15,8 @@ arguments: - expression tests: - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/#use-in--group-stage' + name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/#use-in--group-stage pipeline: - $sort: @@ -26,30 +26,76 @@ tests: $group: _id: day: - # Example uses the short form, the builder always generates the verbose form - # $dayOfYear: '$date' $dayOfYear: - date: '$date' + date: $date year: - # Example uses the short form, the builder always generates the verbose form - # $year: '$date' $year: - date: '$date' + date: $date itemsSold: $push: - item: '$item' - quantity: '$quantity' + item: $item + quantity: $quantity + schema: + sales: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/#use-in--setwindowfields-stage' + name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/#use-in--setwindowfields-stage pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: quantitiesForState: - $push: '$quantity' + $push: $quantity window: - documents: ['unbounded', 'current'] + documents: + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/rank.yaml b/generator/config/accumulator/rank.yaml index 8b8fd041b..0b6bf37c9 100644 --- a/generator/config/accumulator/rank.yaml +++ b/generator/config/accumulator/rank.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $rank -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/rank/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/rank/ type: - window encode: object @@ -9,26 +9,78 @@ description: | New in MongoDB 5.0. tests: - - name: 'Rank Partitions by an Integer Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/rank/#rank-partitions-by-an-integer-field' + name: Rank Partitions by an Integer Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/rank/#rank-partitions-by-an-integer-field pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: quantity: -1 output: rankQuantityForState: $rank: {} + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number - - name: 'Rank Partitions by a Date Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/rank/#rank-partitions-by-a-date-field' + name: Rank Partitions by a Date Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/rank/#rank-partitions-by-a-date-field pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: rankOrderDateForState: $rank: {} + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/shift.yaml b/generator/config/accumulator/shift.yaml index f4984f056..5d908f385 100644 --- a/generator/config/accumulator/shift.yaml +++ b/generator/config/accumulator/shift.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $shift -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/shift/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/shift/ type: - window encode: object @@ -34,32 +34,84 @@ arguments: If you do not specify a default expression, $shift returns null for documents whose positions are outside of the implicit $setWindowFields stage window. tests: - - name: 'Shift Using a Positive Integer' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/shift/#shift-using-a-positive-integer' + name: Shift Using a Positive Integer + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/shift/#shift-using-a-positive-integer pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: quantity: -1 output: shiftQuantityForState: $shift: - output: '$quantity' + output: $quantity by: 1 - default: 'Not available' + default: Not available + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number - - name: 'Shift Using a Negative Integer' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/shift/#shift-using-a-negative-integer' + name: Shift Using a Negative Integer + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/shift/#shift-using-a-negative-integer pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: quantity: -1 output: shiftQuantityForState: $shift: - output: '$quantity' + output: $quantity by: -1 - default: 'Not available' + default: Not available + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/stdDevPop.yaml b/generator/config/accumulator/stdDevPop.yaml index 8916456d4..3cc1fbeff 100644 --- a/generator/config/accumulator/stdDevPop.yaml +++ b/generator/config/accumulator/stdDevPop.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $stdDevPop -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/ type: - accumulator - window @@ -16,25 +16,71 @@ arguments: - resolvesToNumber tests: - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#use-in--group-stage' + name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#use-in--group-stage pipeline: - $group: - _id: '$quiz' + _id: $quiz stdDev: - $stdDevPop: '$score' + $stdDevPop: $score + schema: + users: + _id: + types: + - + bsonType: Number + name: + types: + - + bsonType: String + quiz: + types: + - + bsonType: Number + score: + types: + - + bsonType: Number - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#use-in--setwindowfields-stage' + name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#use-in--setwindowfields-stage pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: stdDevPopQuantityForState: - $stdDevPop: '$quantity' + $stdDevPop: $quantity window: - documents: ['unbounded', 'current'] + documents: + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/stdDevSamp.yaml b/generator/config/accumulator/stdDevSamp.yaml index 94ac33d15..b85c1cfb5 100644 --- a/generator/config/accumulator/stdDevSamp.yaml +++ b/generator/config/accumulator/stdDevSamp.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $stdDevSamp -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/ type: - accumulator - window @@ -16,28 +16,70 @@ arguments: - resolvesToNumber tests: - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/#use-in--group-stage' + name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/#use-in--group-stage pipeline: - $sample: size: 100 - $group: - _id: ~ + _id: null ageStdDev: - $stdDevSamp: '$age' + $stdDevSamp: $age + schema: + TestCollection: + _id: + types: + - + bsonType: Number + username: + types: + - + bsonType: String + age: + types: + - + bsonType: Number - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/#use-in--setwindowfields-stage' + name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/#use-in--setwindowfields-stage pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: stdDevSampQuantityForState: - $stdDevSamp: '$quantity' + $stdDevSamp: $quantity window: - documents: ['unbounded', 'current'] + documents: + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/sum.yaml b/generator/config/accumulator/sum.yaml index c40417ef4..b3065c841 100644 --- a/generator/config/accumulator/sum.yaml +++ b/generator/config/accumulator/sum.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $sum -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/ type: - accumulator - window @@ -15,42 +15,86 @@ arguments: - resolvesToNumber tests: - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/#use-in--group-stage' + name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/#use-in--group-stage pipeline: - $group: _id: day: - # Example uses the short form, the builder always generates the verbose form - # $dayOfYear: '$date' $dayOfYear: - date: '$date' + date: $date year: - # Example uses the short form, the builder always generates the verbose form - # $year: '$date' $year: - date: '$date' + date: $date totalAmount: $sum: $multiply: - - '$price' - - '$quantity' + - $price + - $quantity count: $sum: 1 + schema: + sales: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/#use-in--setwindowfields-stage' + name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/#use-in--setwindowfields-stage pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: sumQuantityForState: - $sum: '$quantity' + $sum: $quantity window: documents: - - 'unbounded' - - 'current' + - unbounded + - current + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/top.yaml b/generator/config/accumulator/top.yaml index 94923cccd..0bb9f69f4 100644 --- a/generator/config/accumulator/top.yaml +++ b/generator/config/accumulator/top.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $top -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/top/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/top/ type: - accumulator encode: object @@ -24,33 +24,61 @@ arguments: Represents the output for each element in the group and can be any expression. tests: - - name: 'Find the Top Score' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/top/#find-the-top-score' + name: Find the Top Score + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/top/#find-the-top-score pipeline: - $match: - gameId: 'G1' + gameId: G1 - $group: - _id: '$gameId' + _id: $gameId playerId: $top: output: - - '$playerId' - - '$score' + - $playerId + - $score sortBy: score: -1 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Find the Top Score Across Multiple Games' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/top/#find-the-top-score-across-multiple-games' + name: Find the Top Score Across Multiple Games + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/top/#find-the-top-score-across-multiple-games pipeline: - $group: - _id: '$gameId' + _id: $gameId playerId: $top: output: - - '$playerId' - - '$score' + - $playerId + - $score sortBy: score: -1 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number diff --git a/generator/config/accumulator/topN.yaml b/generator/config/accumulator/topN.yaml index c5eff6056..7848b0af7 100644 --- a/generator/config/accumulator/topN.yaml +++ b/generator/config/accumulator/topN.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $topN -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/topN/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/topN/ type: - accumulator encode: object @@ -30,56 +30,98 @@ arguments: Represents the output for each element in the group and can be any expression. tests: - - name: 'Find the Three Highest Scores' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/topN/#find-the-three-highest-scores' + name: Find the Three Highest Scores + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/topN/#find-the-three-highest-scores pipeline: - $match: - gameId: 'G1' + gameId: G1 - $group: - _id: '$gameId' + _id: $gameId playerId: $topN: output: - - '$playerId' - - '$score' + - $playerId + - $score sortBy: score: -1 - n: 3 + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Finding the Three Highest Score Documents Across Multiple Games' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/topN/#finding-the-three-highest-score-documents-across-multiple-games' + name: Finding the Three Highest Score Documents Across Multiple Games + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/topN/#finding-the-three-highest-score-documents-across-multiple-games pipeline: - $group: - _id: '$gameId' + _id: $gameId playerId: $topN: output: - - '$playerId' - - '$score' + - $playerId + - $score sortBy: score: -1 - n: 3 + 'n': 3 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number - - name: 'Computing n Based on the Group Key for $group' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/topN/#computing-n-based-on-the-group-key-for--group' + name: Computing n Based on the Group Key for $group + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/topN/#computing-n-based-on-the-group-key-for--group pipeline: - $group: _id: - gameId: '$gameId' + gameId: $gameId gamescores: $topN: - output: '$score' - n: + output: $score + 'n': $cond: if: $eq: - - '$gameId' - - 'G2' + - $gameId + - G2 then: 1 else: 3 sortBy: score: -1 + schema: + gamescores: + playerId: + types: + - + bsonType: String + gameId: + types: + - + bsonType: String + score: + types: + - + bsonType: Number diff --git a/generator/config/expression/abs.yaml b/generator/config/expression/abs.yaml index fe29e44e3..1bd154de4 100644 --- a/generator/config/expression/abs.yaml +++ b/generator/config/expression/abs.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $abs -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/ type: - resolvesToNumber encode: single @@ -13,13 +13,27 @@ arguments: - resolvesToNumber tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/#example pipeline: - $project: delta: $abs: $subtract: - - '$startTemp' - - '$endTemp' + - $startTemp + - $endTemp + schema: + temperatureChange: + _id: + types: + - + bsonType: Number + startTemp: + types: + - + bsonType: Number + endTemp: + types: + - + bsonType: Number diff --git a/generator/config/expression/acos.yaml b/generator/config/expression/acos.yaml index 7deca736d..e0a4e20b6 100644 --- a/generator/config/expression/acos.yaml +++ b/generator/config/expression/acos.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $acos -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/acos/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/acos/ type: - resolvesToDouble - resolvesToDecimal @@ -18,8 +18,8 @@ arguments: By default $acos returns values as a double. $acos can also return values as a 128-bit decimal as long as the expression resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/acos/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/acos/#example pipeline: - $addFields: @@ -27,5 +27,23 @@ tests: $radiansToDegrees: $acos: $divide: - - '$side_b' - - '$hypotenuse' + - $side_b + - $hypotenuse + schema: + TestCollection: + _id: + types: + - + bsonType: ObjectId + side_a: + types: + - + bsonType: Decimal128 + side_b: + types: + - + bsonType: Decimal128 + hypotenuse: + types: + - + bsonType: Decimal128 diff --git a/generator/config/expression/acosh.yaml b/generator/config/expression/acosh.yaml index ce575e317..eda4319f4 100644 --- a/generator/config/expression/acosh.yaml +++ b/generator/config/expression/acosh.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $acosh -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/acosh/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/acosh/ type: - resolvesToDouble - resolvesToDecimal @@ -18,11 +18,21 @@ arguments: By default $acosh returns values as a double. $acosh can also return values as a 128-bit decimal as long as the expression resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/acosh/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/acosh/#example pipeline: - $addFields: y-coordinate: $radiansToDegrees: - $acosh: '$x-coordinate' + $acosh: $x-coordinate + schema: + TestCollection: + _id: + types: + - + bsonType: ObjectId + x-coordinate: + types: + - + bsonType: Decimal128 diff --git a/generator/config/expression/add.yaml b/generator/config/expression/add.yaml index fa23253d0..d85af3aa0 100644 --- a/generator/config/expression/add.yaml +++ b/generator/config/expression/add.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $add -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/ type: - resolvesToInt - resolvesToLong @@ -21,24 +21,68 @@ arguments: The arguments can be any valid expression as long as they resolve to either all numbers or to numbers and a date. tests: - - name: 'Add Numbers' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/#add-numbers' + name: Add Numbers + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/#add-numbers pipeline: - $project: item: 1 total: $add: - - '$price' - - '$fee' + - $price + - $fee + schema: + TestCollection: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + fee: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date - - name: 'Perform Addition on a Date' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/#perform-addition-on-a-date' + name: Perform Addition on a Date + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/#perform-addition-on-a-date pipeline: - $project: item: 1 billing_date: $add: - - '$date' + - $date - 259200000 + schema: + TestCollection: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + fee: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date diff --git a/generator/config/expression/allElementsTrue.yaml b/generator/config/expression/allElementsTrue.yaml index 7301f8d68..8d2b51e7f 100644 --- a/generator/config/expression/allElementsTrue.yaml +++ b/generator/config/expression/allElementsTrue.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $allElementsTrue -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/allElementsTrue/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/allElementsTrue/ type: - resolvesToBool encode: array @@ -13,13 +13,41 @@ arguments: - resolvesToArray tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/allElementsTrue/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/allElementsTrue/#example pipeline: - $project: responses: 1 isAllTrue: $allElementsTrue: - - '$responses' + - $responses _id: 0 + schema: + survey: + _id: + types: + - + bsonType: Number + responses: + types: + - + bsonType: Array + types: + - + bsonType: Boolean + - + bsonType: Array + types: + - + bsonType: Number + - + bsonType: Boolean + - + bsonType: Number + - + bsonType: String + - + bsonType: 'Null' + - + bsonType: Undefined diff --git a/generator/config/expression/and.yaml b/generator/config/expression/and.yaml index 96057d249..a5c79681f 100644 --- a/generator/config/expression/and.yaml +++ b/generator/config/expression/and.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $and -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/ type: - resolvesToBool encode: single @@ -18,8 +18,8 @@ arguments: variadic: array tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/#example pipeline: - $project: @@ -29,9 +29,27 @@ tests: $and: - $gt: - - '$qty' + - $qty - 100 - $lt: - - '$qty' + - $qty - 250 + schema: + inventory: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + description: + types: + - + bsonType: String + qty: + types: + - + bsonType: Number diff --git a/generator/config/expression/anyElementTrue.yaml b/generator/config/expression/anyElementTrue.yaml index 50fe665b6..2024138a1 100644 --- a/generator/config/expression/anyElementTrue.yaml +++ b/generator/config/expression/anyElementTrue.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $anyElementTrue -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/anyElementTrue/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/anyElementTrue/ type: - resolvesToBool encode: array @@ -13,13 +13,41 @@ arguments: - resolvesToArray tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/anyElementTrue/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/anyElementTrue/#example pipeline: - $project: responses: 1 isAnyTrue: $anyElementTrue: - - '$responses' + - $responses _id: 0 + schema: + survey: + _id: + types: + - + bsonType: Number + responses: + types: + - + bsonType: Array + types: + - + bsonType: Boolean + - + bsonType: Array + types: + - + bsonType: Number + - + bsonType: Boolean + - + bsonType: Number + - + bsonType: String + - + bsonType: 'Null' + - + bsonType: Undefined diff --git a/generator/config/expression/arrayElemAt.yaml b/generator/config/expression/arrayElemAt.yaml index 09fe9dae1..2255779ef 100644 --- a/generator/config/expression/arrayElemAt.yaml +++ b/generator/config/expression/arrayElemAt.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $arrayElemAt -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/ type: - resolvesToAny encode: array @@ -17,17 +17,34 @@ arguments: - resolvesToInt tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/#example pipeline: - $project: name: 1 first: $arrayElemAt: - - '$favorites' + - $favorites - 0 last: $arrayElemAt: - - '$favorites' + - $favorites - -1 + schema: + TestCollection: + _id: + types: + - + bsonType: Number + name: + types: + - + bsonType: String + favorites: + types: + - + bsonType: Array + types: + - + bsonType: String diff --git a/generator/config/expression/arrayToObject.yaml b/generator/config/expression/arrayToObject.yaml index 87026f7a7..1f4babc68 100644 --- a/generator/config/expression/arrayToObject.yaml +++ b/generator/config/expression/arrayToObject.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $arrayToObject -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/ type: - resolvesToObject encode: array @@ -13,38 +13,98 @@ arguments: - resolvesToArray tests: - - name: '$arrayToObject Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/#-arraytoobject--example' + name: $arrayToObject Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/#-arraytoobject--example pipeline: - $project: item: 1 dimensions: - # Example uses the short form, the builder always generates the verbose form - # $arrayToObject: '$dimensions' $arrayToObject: - - '$dimensions' + - $dimensions + schema: + inventory: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + dimensions: + types: + - + bsonType: Array + types: + - + bsonType: Array + types: + - + bsonType: String + - + bsonType: Number + - + bsonType: Document + fields: + k: + types: + - + bsonType: String + v: + types: + - + bsonType: Number + - + bsonType: String - - name: '$objectToArray and $arrayToObject Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/#-objecttoarray----arraytoobject-example' + name: $objectToArray and $arrayToObject Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/#-objecttoarray----arraytoobject-example pipeline: - $addFields: instock: - $objectToArray: '$instock' + $objectToArray: $instock - $addFields: instock: $concatArrays: - - '$instock' + - $instock - - - k: 'total' + k: total v: $sum: - - '$instock.v' + - $instock.v - $addFields: instock: $arrayToObject: - - '$instock' + - $instock + schema: + inventory: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + instock: + types: + - + bsonType: Document + fields: + warehouse1: + types: + - + bsonType: Number + warehouse2: + types: + - + bsonType: Number + warehouse3: + types: + - + bsonType: Number diff --git a/generator/config/expression/asin.yaml b/generator/config/expression/asin.yaml index 43e2832a2..42af7dc69 100644 --- a/generator/config/expression/asin.yaml +++ b/generator/config/expression/asin.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $asin -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/asin/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/asin/ type: - resolvesToDouble - resolvesToDecimal @@ -18,8 +18,8 @@ arguments: By default $asin returns values as a double. $asin can also return values as a 128-bit decimal as long as the expression resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/asin/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/asin/#example pipeline: - $addFields: @@ -27,5 +27,23 @@ tests: $radiansToDegrees: $asin: $divide: - - '$side_a' - - '$hypotenuse' + - $side_a + - $hypotenuse + schema: + TestCollection: + _id: + types: + - + bsonType: ObjectId + side_a: + types: + - + bsonType: Decimal128 + side_b: + types: + - + bsonType: Decimal128 + hypotenuse: + types: + - + bsonType: Decimal128 diff --git a/generator/config/expression/asinh.yaml b/generator/config/expression/asinh.yaml index 6d45c14fa..15a40020c 100644 --- a/generator/config/expression/asinh.yaml +++ b/generator/config/expression/asinh.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $asinh -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/asinh/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/asinh/ type: - resolvesToDouble - resolvesToDecimal @@ -18,11 +18,21 @@ arguments: By default $asinh returns values as a double. $asinh can also return values as a 128-bit decimal as long as the expression resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/asinh/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/asinh/#example pipeline: - $addFields: y-coordinate: $radiansToDegrees: - $asinh: '$x-coordinate' + $asinh: $x-coordinate + schema: + TestCollection: + _id: + types: + - + bsonType: ObjectId + x-coordinate: + types: + - + bsonType: Decimal128 diff --git a/generator/config/expression/atan.yaml b/generator/config/expression/atan.yaml index a8bb1674f..e8b022c08 100644 --- a/generator/config/expression/atan.yaml +++ b/generator/config/expression/atan.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $atan -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan/ type: - resolvesToDouble - resolvesToDecimal @@ -18,8 +18,8 @@ arguments: By default $atan returns values as a double. $atan can also return values as a 128-bit decimal as long as the expression resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan/#example pipeline: - $addFields: @@ -27,5 +27,23 @@ tests: $radiansToDegrees: $atan: $divide: - - '$side_b' - - '$side_a' + - $side_b + - $side_a + schema: + TestCollection: + _id: + types: + - + bsonType: ObjectId + side_a: + types: + - + bsonType: Decimal128 + side_b: + types: + - + bsonType: Decimal128 + hypotenuse: + types: + - + bsonType: Decimal128 diff --git a/generator/config/expression/atan2.yaml b/generator/config/expression/atan2.yaml index 1abc55e6a..235f96d64 100644 --- a/generator/config/expression/atan2.yaml +++ b/generator/config/expression/atan2.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $atan2 -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/ type: - resolvesToDouble - resolvesToDecimal @@ -22,13 +22,31 @@ arguments: - resolvesToNumber tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/#example pipeline: - $addFields: angle_a: $radiansToDegrees: $atan2: - - '$side_b' - - '$side_a' + - $side_b + - $side_a + schema: + TestCollection: + _id: + types: + - + bsonType: ObjectId + side_a: + types: + - + bsonType: Decimal128 + side_b: + types: + - + bsonType: Decimal128 + hypotenuse: + types: + - + bsonType: Decimal128 diff --git a/generator/config/expression/atanh.yaml b/generator/config/expression/atanh.yaml index 501fba2bf..90dedab3c 100644 --- a/generator/config/expression/atanh.yaml +++ b/generator/config/expression/atanh.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $atanh -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/atanh/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/atanh/ type: - resolvesToDouble - resolvesToDecimal @@ -18,11 +18,21 @@ arguments: By default $atanh returns values as a double. $atanh can also return values as a 128-bit decimal as long as the expression resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/atanh/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/atanh/#example pipeline: - $addFields: y-coordinate: $radiansToDegrees: - $atanh: '$x-coordinate' + $atanh: $x-coordinate + schema: + TestCollection: + _id: + types: + - + bsonType: ObjectId + x-coordinate: + types: + - + bsonType: Decimal128 diff --git a/generator/config/expression/avg.yaml b/generator/config/expression/avg.yaml index 3bb771936..309efd350 100644 --- a/generator/config/expression/avg.yaml +++ b/generator/config/expression/avg.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $avg -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/ type: - resolvesToNumber encode: single @@ -15,21 +15,46 @@ arguments: variadic: array tests: - - name: 'Use in $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--project-stage' + name: Use in $project Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--project-stage pipeline: - $project: quizAvg: - # Example uses the short form, the builder always generates the verbose form - # $avg: '$quizzes' $avg: - - '$quizzes' + - $quizzes labAvg: - # $avg: '$labs' $avg: - - '$labs' + - $labs examAvg: $avg: - - '$final' - - '$midterm' + - $final + - $midterm + schema: + TestCollection: + _id: + types: + - + bsonType: Number + quizzes: + types: + - + bsonType: Array + types: + - + bsonType: Number + labs: + types: + - + bsonType: Array + types: + - + bsonType: Number + final: + types: + - + bsonType: Number + midterm: + types: + - + bsonType: Number diff --git a/generator/config/expression/binarySize.yaml b/generator/config/expression/binarySize.yaml index eb0146f8c..0c517da8f 100644 --- a/generator/config/expression/binarySize.yaml +++ b/generator/config/expression/binarySize.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $binarySize -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/ type: - resolvesToInt encode: single @@ -15,11 +15,25 @@ arguments: - resolvesToNull tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/#example pipeline: - $project: - name: '$name' + name: $name imageSize: - $binarySize: '$binary' + $binarySize: $binary + schema: + images: + _id: + types: + - + bsonType: Number + name: + types: + - + bsonType: String + binary: + types: + - + bsonType: Binary diff --git a/generator/config/expression/bitAnd.yaml b/generator/config/expression/bitAnd.yaml index 271cc0973..acc06474e 100644 --- a/generator/config/expression/bitAnd.yaml +++ b/generator/config/expression/bitAnd.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bitAnd -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitAnd/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitAnd/ type: - resolvesToInt - resolvesToLong @@ -17,22 +17,51 @@ arguments: variadic: array tests: - - name: 'Bitwise AND with Two Integers' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitAnd/#bitwise-and-with-two-integers' + name: Bitwise AND with Two Integers + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitAnd/#bitwise-and-with-two-integers pipeline: - $project: result: $bitAnd: - - '$a' - - '$b' + - $a + - $b + schema: + switches: + _id: + types: + - + bsonType: Number + a: + types: + - + bsonType: Int32 + b: + types: + - + bsonType: Int32 - - name: 'Bitwise AND with a Long and Integer' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitAnd/#bitwise-and-with-a-long-and-integer' + name: Bitwise AND with a Long and Integer + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitAnd/#bitwise-and-with-a-long-and-integer pipeline: - $project: result: $bitAnd: - - '$a' - - { "$numberLong": "63" } + - $a + - + $numberLong: '63' + schema: + switches: + _id: + types: + - + bsonType: Number + a: + types: + - + bsonType: Int32 + b: + types: + - + bsonType: Int32 diff --git a/generator/config/expression/bitNot.yaml b/generator/config/expression/bitNot.yaml index 5211fa42a..b8a24c856 100644 --- a/generator/config/expression/bitNot.yaml +++ b/generator/config/expression/bitNot.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bitNot -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitNot/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitNot/ type: - resolvesToInt - resolvesToLong @@ -16,10 +16,24 @@ arguments: - resolvesToLong tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitNot/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitNot/#example pipeline: - $project: result: - $bitNot: '$a' + $bitNot: $a + schema: + switches: + _id: + types: + - + bsonType: Number + a: + types: + - + bsonType: Int32 + b: + types: + - + bsonType: Int32 diff --git a/generator/config/expression/bitOr.yaml b/generator/config/expression/bitOr.yaml index 084ac224c..4ad7eeb7d 100644 --- a/generator/config/expression/bitOr.yaml +++ b/generator/config/expression/bitOr.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bitOr -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitOr/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitOr/ type: - resolvesToInt - resolvesToLong @@ -17,22 +17,51 @@ arguments: variadic: array tests: - - name: 'Bitwise OR with Two Integers' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitOr/#bitwise-or-with-two-integers' + name: Bitwise OR with Two Integers + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitOr/#bitwise-or-with-two-integers pipeline: - $project: result: $bitOr: - - '$a' - - '$b' + - $a + - $b + schema: + switches: + _id: + types: + - + bsonType: Number + a: + types: + - + bsonType: Int32 + b: + types: + - + bsonType: Int32 - - name: 'Bitwise OR with a Long and Integer' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitOr/#bitwise-or-with-a-long-and-integer' + name: Bitwise OR with a Long and Integer + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitOr/#bitwise-or-with-a-long-and-integer pipeline: - $project: result: $bitOr: - - '$a' - - { "$numberLong": "63" } + - $a + - + $numberLong: '63' + schema: + switches: + _id: + types: + - + bsonType: Number + a: + types: + - + bsonType: Int32 + b: + types: + - + bsonType: Int32 diff --git a/generator/config/expression/bitXor.yaml b/generator/config/expression/bitXor.yaml index f4acc4df4..a7bcd983a 100644 --- a/generator/config/expression/bitXor.yaml +++ b/generator/config/expression/bitXor.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bitXor -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitXor/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitXor/ type: - resolvesToInt - resolvesToLong @@ -17,12 +17,26 @@ arguments: variadic: array tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitXor/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitXor/#example pipeline: - $project: result: $bitXor: - - '$a' - - '$b' + - $a + - $b + schema: + switches: + _id: + types: + - + bsonType: Number + a: + types: + - + bsonType: Int32 + b: + types: + - + bsonType: Int32 diff --git a/generator/config/expression/bsonSize.yaml b/generator/config/expression/bsonSize.yaml index 712188c52..885e6a5cf 100644 --- a/generator/config/expression/bsonSize.yaml +++ b/generator/config/expression/bsonSize.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bsonSize -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/ type: - resolvesToInt encode: single @@ -14,35 +14,170 @@ arguments: - resolvesToNull tests: - - name: 'Return Sizes of Documents' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/#return-sizes-of-documents' + name: Return Sizes of Documents + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/#return-sizes-of-documents pipeline: - $project: name: 1 object_size: - $bsonSize: '$$ROOT' + $bsonSize: $$ROOT + schema: + employees: + _id: + types: + - + bsonType: Number + name: + types: + - + bsonType: String + email: + types: + - + bsonType: String + position: + types: + - + bsonType: String + current_task: + types: + - + bsonType: Document + fields: + project_id: + types: + - + bsonType: Number + project_name: + types: + - + bsonType: String + project_duration: + types: + - + bsonType: Number + hours: + types: + - + bsonType: Number + notes: + types: + - + bsonType: String + - + bsonType: 'Null' - - name: 'Return Combined Size of All Documents in a Collection' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/#return-combined-size-of-all-documents-in-a-collection' + name: Return Combined Size of All Documents in a Collection + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/#return-combined-size-of-all-documents-in-a-collection pipeline: - $group: - _id: ~ + _id: null combined_object_size: $sum: - $bsonSize: '$$ROOT' + $bsonSize: $$ROOT + schema: + employees: + _id: + types: + - + bsonType: Number + name: + types: + - + bsonType: String + email: + types: + - + bsonType: String + position: + types: + - + bsonType: String + current_task: + types: + - + bsonType: Document + fields: + project_id: + types: + - + bsonType: Number + project_name: + types: + - + bsonType: String + project_duration: + types: + - + bsonType: Number + hours: + types: + - + bsonType: Number + notes: + types: + - + bsonType: String + - + bsonType: 'Null' - - name: 'Return Document with Largest Specified Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/#return-document-with-largest-specified-field' + name: Return Document with Largest Specified Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/#return-document-with-largest-specified-field pipeline: - $project: - name: '$name' + name: $name task_object_size: - $bsonSize: '$current_task' + $bsonSize: $current_task - $sort: task_object_size: -1 - $limit: 1 + schema: + employees: + _id: + types: + - + bsonType: Number + name: + types: + - + bsonType: String + email: + types: + - + bsonType: String + position: + types: + - + bsonType: String + current_task: + types: + - + bsonType: Document + fields: + project_id: + types: + - + bsonType: Number + project_name: + types: + - + bsonType: String + project_duration: + types: + - + bsonType: Number + hours: + types: + - + bsonType: Number + notes: + types: + - + bsonType: String + - + bsonType: 'Null' diff --git a/generator/config/expression/case.yaml b/generator/config/expression/case.yaml index ccf463c90..4cdfd0988 100644 --- a/generator/config/expression/case.yaml +++ b/generator/config/expression/case.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $case -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/ type: - switchBranch encode: object diff --git a/generator/config/expression/ceil.yaml b/generator/config/expression/ceil.yaml index 73c31ddb7..96afa94cb 100644 --- a/generator/config/expression/ceil.yaml +++ b/generator/config/expression/ceil.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $ceil -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/ type: - resolvesToInt encode: single @@ -15,11 +15,21 @@ arguments: If the argument resolves to a value of null or refers to a field that is missing, $ceil returns null. If the argument resolves to NaN, $ceil returns NaN. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/#example pipeline: - $project: value: 1 ceilingValue: - $ceil: '$value' + $ceil: $value + schema: + samples: + _id: + types: + - + bsonType: Number + value: + types: + - + bsonType: Number diff --git a/generator/config/expression/cmp.yaml b/generator/config/expression/cmp.yaml index dd24f9839..1d8bd6a69 100644 --- a/generator/config/expression/cmp.yaml +++ b/generator/config/expression/cmp.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $cmp -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/ type: - resolvesToInt encode: array @@ -17,8 +17,8 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/#example pipeline: - $project: @@ -26,6 +26,24 @@ tests: qty: 1 cmpTo250: $cmp: - - '$qty' + - $qty - 250 _id: 0 + schema: + inventory: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + description: + types: + - + bsonType: String + qty: + types: + - + bsonType: Number diff --git a/generator/config/expression/concat.yaml b/generator/config/expression/concat.yaml index e8b218d82..69cee5a7d 100644 --- a/generator/config/expression/concat.yaml +++ b/generator/config/expression/concat.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $concat -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/ type: - resolvesToString encode: single @@ -14,13 +14,14 @@ arguments: variadic: array tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/#examples' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/#examples pipeline: - $project: itemDescription: $concat: - - '$item' + - $item - ' - ' - - '$description' + - $description + schema: '// TODO: No schema found in docs' diff --git a/generator/config/expression/concatArrays.yaml b/generator/config/expression/concatArrays.yaml index 026541092..cf5777f5e 100644 --- a/generator/config/expression/concatArrays.yaml +++ b/generator/config/expression/concatArrays.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $concatArrays -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/ type: - resolvesToArray encode: single @@ -14,12 +14,32 @@ arguments: variadic: array tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/#example pipeline: - $project: items: $concatArrays: - - '$instock' - - '$ordered' + - $instock + - $ordered + schema: + warehouses: + _id: + types: + - + bsonType: Number + instock: + types: + - + bsonType: Array + types: + - + bsonType: String + ordered: + types: + - + bsonType: Array + types: + - + bsonType: String diff --git a/generator/config/expression/cond.yaml b/generator/config/expression/cond.yaml index e2fd66ad7..e9b62d065 100644 --- a/generator/config/expression/cond.yaml +++ b/generator/config/expression/cond.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $cond -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/ type: - resolvesToAny encode: object @@ -21,8 +21,8 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/#example pipeline: - $project: @@ -31,7 +31,21 @@ tests: $cond: if: $gte: - - '$qty' + - $qty - 250 then: 30 else: 20 + schema: + TestCollection: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + qty: + types: + - + bsonType: Number diff --git a/generator/config/expression/convert.yaml b/generator/config/expression/convert.yaml index a76311ed5..2a5951e60 100644 --- a/generator/config/expression/convert.yaml +++ b/generator/config/expression/convert.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $convert -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/ type: - resolvesToAny encode: object @@ -35,26 +35,27 @@ arguments: If unspecified, $convert returns null if the input is null or missing. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/#example pipeline: - $addFields: convertedPrice: $convert: - input: '$price' - to: 'decimal' - onError: 'Error' - onNull: !bson_decimal128 '0' + input: $price + to: decimal + onError: Error + onNull: + bytes: !!binary AAAAAAAAAAAAAAAAAABAMA== convertedQty: $convert: - input: '$qty' - to: 'int' + input: $qty + to: int onError: $concat: - 'Could not convert ' - - $toString: '$qty' + $toString: $qty - ' to type integer.' onNull: 0 - @@ -66,17 +67,39 @@ tests: case: $eq: - - $type: '$convertedPrice' - - 'string' - then: 'NaN' + $type: $convertedPrice + - string + then: NaN - case: $eq: - - $type: '$convertedQty' - - 'string' - then: 'NaN' + $type: $convertedQty + - string + then: NaN default: $multiply: - - '$convertedPrice' - - '$convertedQty' + - $convertedPrice + - $convertedQty + schema: + orders: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + qty: + types: + - + bsonType: Number + price: + types: + - + bsonType: Decimal128 + - + bsonType: Number + - + bsonType: String diff --git a/generator/config/expression/cos.yaml b/generator/config/expression/cos.yaml index 0b47670cf..82f2b02cc 100644 --- a/generator/config/expression/cos.yaml +++ b/generator/config/expression/cos.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $cos -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/cos/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cos/ type: - resolvesToDouble - resolvesToDecimal @@ -17,8 +17,8 @@ arguments: By default $cos returns values as a double. $cos can also return values as a 128-bit decimal as long as the resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/cos/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cos/#example pipeline: - $addFields: @@ -26,5 +26,19 @@ tests: $multiply: - $cos: - $degreesToRadians: '$angle_a' - - '$hypotenuse' + $degreesToRadians: $angle_a + - $hypotenuse + schema: + TestCollection: + _id: + types: + - + bsonType: ObjectId + angle_a: + types: + - + bsonType: Decimal128 + hypotenuse: + types: + - + bsonType: Decimal128 diff --git a/generator/config/expression/cosh.yaml b/generator/config/expression/cosh.yaml index 419fa8caa..a0c797062 100644 --- a/generator/config/expression/cosh.yaml +++ b/generator/config/expression/cosh.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $cosh -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/cosh/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cosh/ type: - resolvesToDouble - resolvesToDecimal @@ -17,11 +17,21 @@ arguments: By default $cosh returns values as a double. $cosh can also return values as a 128-bit decimal if the resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/cosh/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cosh/#example pipeline: - $addFields: cosh_output: $cosh: - $degreesToRadians: '$angle' + $degreesToRadians: $angle + schema: + trigonometry: + _id: + types: + - + bsonType: ObjectId + angle: + types: + - + bsonType: Decimal128 diff --git a/generator/config/expression/dateAdd.yaml b/generator/config/expression/dateAdd.yaml index c7d85d571..b69828d60 100644 --- a/generator/config/expression/dateAdd.yaml +++ b/generator/config/expression/dateAdd.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $dateAdd -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/ type: - resolvesToDate encode: object @@ -35,34 +35,42 @@ arguments: The timezone to carry out the operation. $timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Add a Future Date' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/#add-a-future-date' + name: Add a Future Date + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/#add-a-future-date pipeline: - $project: expectedDeliveryDate: $dateAdd: - startDate: '$purchaseDate' - unit: 'day' + startDate: $purchaseDate + unit: day amount: 3 - - # Example uses the short form, the builder always generates the verbose form - # $merge: 'shipping' $merge: - into: 'shipping' + into: shipping + schema: + shipping: + custId: + types: + - + bsonType: Number + purchaseDate: + types: + - + bsonType: Date - - name: 'Filter on a Date Range' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/#filter-on-a-date-range' + name: Filter on a Date Range + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/#filter-on-a-date-range pipeline: - $match: $expr: $gt: - - '$deliveryDate' + - $deliveryDate - $dateAdd: - startDate: '$purchaseDate' - unit: 'day' + startDate: $purchaseDate + unit: day amount: 5 - $project: @@ -71,14 +79,24 @@ tests: purchased: $dateToString: format: '%Y-%m-%d' - date: '$purchaseDate' + date: $purchaseDate delivery: $dateToString: format: '%Y-%m-%d' - date: '$deliveryDate' + date: $deliveryDate + schema: + shipping: + custId: + types: + - + bsonType: Number + purchaseDate: + types: + - + bsonType: Date - - name: 'Adjust for Daylight Savings Time' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/#adjust-for-daylight-savings-time' + name: Adjust for Daylight Savings Time + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/#adjust-for-daylight-savings-time pipeline: - $project: @@ -87,47 +105,61 @@ tests: start: $dateToString: format: '%Y-%m-%d %H:%M' - date: '$login' + date: $login days: $dateToString: format: '%Y-%m-%d %H:%M' date: $dateAdd: - startDate: '$login' - unit: 'day' + startDate: $login + unit: day amount: 1 - timezone: '$location' + timezone: $location hours: $dateToString: format: '%Y-%m-%d %H:%M' date: $dateAdd: - startDate: '$login' - unit: 'hour' + startDate: $login + unit: hour amount: 24 - timezone: '$location' + timezone: $location startTZInfo: $dateToString: format: '%Y-%m-%d %H:%M' - date: '$login' - timezone: '$location' + date: $login + timezone: $location daysTZInfo: $dateToString: format: '%Y-%m-%d %H:%M' date: $dateAdd: - startDate: '$login' - unit: 'day' + startDate: $login + unit: day amount: 1 - timezone: '$location' - timezone: '$location' + timezone: $location + timezone: $location hoursTZInfo: $dateToString: format: '%Y-%m-%d %H:%M' date: $dateAdd: - startDate: '$login' - unit: 'hour' + startDate: $login + unit: hour amount: 24 - timezone: '$location' - timezone: '$location' + timezone: $location + timezone: $location + schema: + billing: + location: + types: + - + bsonType: String + login: + types: + - + bsonType: Date + logout: + types: + - + bsonType: Date diff --git a/generator/config/expression/dateDiff.yaml b/generator/config/expression/dateDiff.yaml index 42cb55d15..3335a32c7 100644 --- a/generator/config/expression/dateDiff.yaml +++ b/generator/config/expression/dateDiff.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $dateDiff -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/ type: - resolvesToInt encode: object @@ -45,70 +45,112 @@ arguments: Used when the unit is equal to week. Defaults to Sunday. The startOfWeek parameter is an expression that resolves to a case insensitive string tests: - - name: 'Elapsed Time' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/#elapsed-time' + name: Elapsed Time + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/#elapsed-time pipeline: - $group: - _id: ~ + _id: null averageTime: $avg: $dateDiff: - startDate: '$purchased' - endDate: '$delivered' - unit: 'day' + startDate: $purchased + endDate: $delivered + unit: day - $project: _id: 0 numDays: $trunc: - - '$averageTime' + - $averageTime - 1 + schema: + orders: + custId: + types: + - + bsonType: Number + purchased: + types: + - + bsonType: Date + delivered: + types: + - + bsonType: Date - - name: 'Result Precision' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/#result-precision' + name: Result Precision + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/#result-precision pipeline: - $project: - Start: '$start' - End: '$end' + Start: $start + End: $end years: $dateDiff: - startDate: '$start' - endDate: '$end' - unit: 'year' + startDate: $start + endDate: $end + unit: year months: $dateDiff: - startDate: '$start' - endDate: '$end' - unit: 'month' + startDate: $start + endDate: $end + unit: month days: $dateDiff: - startDate: '$start' - endDate: '$end' - unit: 'day' + startDate: $start + endDate: $end + unit: day _id: 0 + schema: + subscriptions: + custId: + types: + - + bsonType: Number + start: + types: + - + bsonType: Date + end: + types: + - + bsonType: Date - - name: 'Weeks Per Month' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/#weeks-per-month' + name: Weeks Per Month + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/#weeks-per-month pipeline: - $project: wks_default: $dateDiff: - startDate: '$start' - endDate: '$end' - unit: 'week' + startDate: $start + endDate: $end + unit: week wks_monday: $dateDiff: - startDate: '$start' - endDate: '$end' - unit: 'week' - startOfWeek: 'Monday' + startDate: $start + endDate: $end + unit: week + startOfWeek: Monday wks_friday: $dateDiff: - startDate: '$start' - endDate: '$end' - unit: 'week' - startOfWeek: 'fri' + startDate: $start + endDate: $end + unit: week + startOfWeek: fri _id: 0 + schema: + months: + month: + types: + - + bsonType: String + start: + types: + - + bsonType: Date + end: + types: + - + bsonType: Date diff --git a/generator/config/expression/dateFromParts.yaml b/generator/config/expression/dateFromParts.yaml index 3ed35004e..c46add05b 100644 --- a/generator/config/expression/dateFromParts.yaml +++ b/generator/config/expression/dateFromParts.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $dateFromParts -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromParts/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromParts/ type: - resolvesToDate encode: object @@ -86,8 +86,8 @@ arguments: The timezone to carry out the operation. $timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromParts/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromParts/#example pipeline: - $project: @@ -111,4 +111,5 @@ tests: hour: 23 minute: 46 second: 12 - timezone: 'America/New_York' + timezone: America/New_York + schema: '// TODO: No schema found in docs' diff --git a/generator/config/expression/dateFromString.yaml b/generator/config/expression/dateFromString.yaml index 713200f5d..e92a85f5e 100644 --- a/generator/config/expression/dateFromString.yaml +++ b/generator/config/expression/dateFromString.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $dateFromString -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/ type: - resolvesToDate encode: object @@ -46,35 +46,82 @@ arguments: If you do not specify onNull and dateString is null or missing, then $dateFromString outputs null. tests: - - name: 'Converting Dates' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/#converting-dates' + name: Converting Dates + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/#converting-dates pipeline: - $project: date: $dateFromString: - dateString: '$date' - timezone: 'America/New_York' + dateString: $date + timezone: America/New_York + schema: + logmessages: + _id: + types: + - + bsonType: Number + date: + types: + - + bsonType: String + timezone: + types: + - + bsonType: String + message: + types: + - + bsonType: String - - name: 'onError' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/#onerror' + name: onError + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/#onerror pipeline: - $project: date: $dateFromString: - dateString: '$date' - timezone: '$timezone' - onError: '$date' + dateString: $date + timezone: $timezone + onError: $date + schema: + TestCollection: + _id: + types: + - + bsonType: Number + date: + types: + - + bsonType: String + timezone: + types: + - + bsonType: String - - name: 'onNull' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/#onnull' + name: onNull + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/#onnull pipeline: - $project: date: $dateFromString: - dateString: '$date' - timezone: '$timezone' - onNull: !bson_utcdatetime 0 - + dateString: $date + timezone: $timezone + onNull: 1999-12-31T23:00:00.000Z + schema: + TestCollection: + _id: + types: + - + bsonType: Number + date: + types: + - + bsonType: String + - + bsonType: 'Null' + timezone: + types: + - + bsonType: String diff --git a/generator/config/expression/dateSubtract.yaml b/generator/config/expression/dateSubtract.yaml index e463fe8f8..c2129fceb 100644 --- a/generator/config/expression/dateSubtract.yaml +++ b/generator/config/expression/dateSubtract.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $dateSubtract -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/ type: - resolvesToDate encode: object @@ -35,44 +35,54 @@ arguments: The timezone to carry out the operation. $timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Subtract A Fixed Amount' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/#subtract-a-fixed-amount' + name: Subtract A Fixed Amount + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/#subtract-a-fixed-amount pipeline: - $match: $expr: $eq: - - # Example uses the short form, the builder always generates the verbose form - # $month: '$logout' $month: - date: '$logout' + date: $logout - 1 - $project: logoutTime: $dateSubtract: - startDate: '$logout' - unit: 'hour' + startDate: $logout + unit: hour amount: 3 - - # Example uses the short form, the builder always generates the verbose form - # $merge: 'connectionTime' $merge: - into: 'connectionTime' + into: connectionTime + schema: + connectionTime: + custId: + types: + - + bsonType: Number + login: + types: + - + bsonType: Date + logout: + types: + - + bsonType: Date - - name: 'Filter by Relative Dates' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/#filter-by-relative-dates' + name: Filter by Relative Dates + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/#filter-by-relative-dates pipeline: - $match: $expr: $gt: - - '$logoutTime' + - $logoutTime - $dateSubtract: - startDate: '$$NOW' - unit: 'week' + startDate: $$NOW + unit: week amount: 1 - $project: @@ -81,10 +91,24 @@ tests: loggedOut: $dateToString: format: '%Y-%m-%d' - date: '$logoutTime' + date: $logoutTime + schema: + connectionTime: + custId: + types: + - + bsonType: Number + login: + types: + - + bsonType: Date + logout: + types: + - + bsonType: Date - - name: 'Adjust for Daylight Savings Time' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/#adjust-for-daylight-savings-time' + name: Adjust for Daylight Savings Time + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/#adjust-for-daylight-savings-time pipeline: - $project: @@ -93,47 +117,61 @@ tests: start: $dateToString: format: '%Y-%m-%d %H:%M' - date: '$login' + date: $login days: $dateToString: format: '%Y-%m-%d %H:%M' date: $dateSubtract: - startDate: '$login' - unit: 'day' + startDate: $login + unit: day amount: 1 - timezone: '$location' + timezone: $location hours: $dateToString: format: '%Y-%m-%d %H:%M' date: $dateSubtract: - startDate: '$login' - unit: 'hour' + startDate: $login + unit: hour amount: 24 - timezone: '$location' + timezone: $location startTZInfo: $dateToString: format: '%Y-%m-%d %H:%M' - date: '$login' - timezone: '$location' + date: $login + timezone: $location daysTZInfo: $dateToString: format: '%Y-%m-%d %H:%M' date: $dateSubtract: - startDate: '$login' - unit: 'day' + startDate: $login + unit: day amount: 1 - timezone: '$location' - timezone: '$location' + timezone: $location + timezone: $location hoursTZInfo: $dateToString: format: '%Y-%m-%d %H:%M' date: $dateSubtract: - startDate: '$login' - unit: 'hour' + startDate: $login + unit: hour amount: 24 - timezone: '$location' - timezone: '$location' + timezone: $location + timezone: $location + schema: + billing: + location: + types: + - + bsonType: String + login: + types: + - + bsonType: Date + logout: + types: + - + bsonType: Date diff --git a/generator/config/expression/dateToParts.yaml b/generator/config/expression/dateToParts.yaml index d250e052f..f3af102ce 100644 --- a/generator/config/expression/dateToParts.yaml +++ b/generator/config/expression/dateToParts.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $dateToParts -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToParts/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToParts/ type: - resolvesToObject encode: object @@ -31,19 +31,41 @@ arguments: If set to true, modifies the output document to use ISO week date fields. Defaults to false. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToParts/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToParts/#example pipeline: - $project: date: $dateToParts: - date: '$date' + date: $date date_iso: $dateToParts: - date: '$date' + date: $date iso8601: true date_timezone: $dateToParts: - date: '$date' - timezone: 'America/New_York' + date: $date + timezone: America/New_York + schema: + sales: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date diff --git a/generator/config/expression/dateToString.yaml b/generator/config/expression/dateToString.yaml index 29e0ea8c8..2b5f23c83 100644 --- a/generator/config/expression/dateToString.yaml +++ b/generator/config/expression/dateToString.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $dateToString -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/ type: - resolvesToString encode: object @@ -40,42 +40,64 @@ arguments: If unspecified, $dateToString returns null if the date is null or missing. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/#example pipeline: - $project: yearMonthDayUTC: $dateToString: format: '%Y-%m-%d' - date: '$date' + date: $date timewithOffsetNY: $dateToString: format: '%H:%M:%S:%L%z' - date: '$date' - timezone: 'America/New_York' + date: $date + timezone: America/New_York timewithOffset430: $dateToString: format: '%H:%M:%S:%L%z' - date: '$date' + date: $date timezone: '+04:30' minutesOffsetNY: $dateToString: format: '%Z' - date: '$date' - timezone: 'America/New_York' + date: $date + timezone: America/New_York minutesOffset430: $dateToString: format: '%Z' - date: '$date' + date: $date timezone: '+04:30' abbreviated_month: $dateToString: format: '%b' - date: '$date' + date: $date timezone: '+04:30' full_month: $dateToString: format: '%B' - date: '$date' + date: $date timezone: '+04:30' + schema: + sales: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date diff --git a/generator/config/expression/dateTrunc.yaml b/generator/config/expression/dateTrunc.yaml index aa3dcd6ca..39ead9566 100644 --- a/generator/config/expression/dateTrunc.yaml +++ b/generator/config/expression/dateTrunc.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $dateTrunc -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/ type: - resolvesToDate encode: object @@ -47,8 +47,8 @@ arguments: unit is week. Defaults to Sunday. tests: - - name: 'Truncate Order Dates in a $project Pipeline Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/#truncate-order-dates-in-a--project-pipeline-stage' + name: Truncate Order Dates in a $project Pipeline Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/#truncate-order-dates-in-a--project-pipeline-stage pipeline: - $project: @@ -56,22 +56,74 @@ tests: orderDate: 1 truncatedOrderDate: $dateTrunc: - date: '$orderDate' - unit: 'week' + date: $orderDate + unit: week binSize: 2 - timezone: 'America/Los_Angeles' - startOfWeek: 'Monday' + timezone: America/Los_Angeles + startOfWeek: Monday + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number - - name: 'Truncate Order Dates and Obtain Quantity Sum in a $group Pipeline Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/#truncate-order-dates-and-obtain-quantity-sum-in-a--group-pipeline-stage' + name: Truncate Order Dates and Obtain Quantity Sum in a $group Pipeline Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/#truncate-order-dates-and-obtain-quantity-sum-in-a--group-pipeline-stage pipeline: - $group: _id: truncatedOrderDate: $dateTrunc: - date: '$orderDate' - unit: 'month' + date: $orderDate + unit: month binSize: 6 sumQuantity: - $sum: '$quantity' + $sum: $quantity + schema: + cakeSales: + _id: + types: + - + bsonType: Number + type: + types: + - + bsonType: String + orderDate: + types: + - + bsonType: Date + state: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number diff --git a/generator/config/expression/dayOfMonth.yaml b/generator/config/expression/dayOfMonth.yaml index 46a4de0b7..6abab37ce 100644 --- a/generator/config/expression/dayOfMonth.yaml +++ b/generator/config/expression/dayOfMonth.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $dayOfMonth -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/ type: - resolvesToInt encode: object @@ -24,13 +24,33 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/#example pipeline: - $project: day: - # Example uses the short form, the builder always generates the verbose form - # $dayOfMonth: '$date' $dayOfMonth: - date: '$date' + date: $date + schema: + sales: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date diff --git a/generator/config/expression/dayOfWeek.yaml b/generator/config/expression/dayOfWeek.yaml index 27a6a809d..46e4d084d 100644 --- a/generator/config/expression/dayOfWeek.yaml +++ b/generator/config/expression/dayOfWeek.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $dayOfWeek -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/ type: - resolvesToInt encode: object @@ -24,13 +24,33 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/#example pipeline: - $project: dayOfWeek: - # Example uses the short form, the builder always generates the verbose form - # $dayOfWeek: '$date' $dayOfWeek: - date: '$date' + date: $date + schema: + sales: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date diff --git a/generator/config/expression/dayOfYear.yaml b/generator/config/expression/dayOfYear.yaml index 8caa0374d..6279e5d50 100644 --- a/generator/config/expression/dayOfYear.yaml +++ b/generator/config/expression/dayOfYear.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $dayOfYear -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/ type: - resolvesToInt encode: object @@ -24,13 +24,33 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/#example pipeline: - $project: dayOfYear: - # Example uses the short form, the builder always generates the verbose form - # $dayOfYear: '$date' $dayOfYear: - date: '$date' + date: $date + schema: + sales: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + price: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + date: + types: + - + bsonType: Date diff --git a/generator/config/expression/degreesToRadians.yaml b/generator/config/expression/degreesToRadians.yaml index 59c18d2e3..7388990c8 100644 --- a/generator/config/expression/degreesToRadians.yaml +++ b/generator/config/expression/degreesToRadians.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $degreesToRadians -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/degreesToRadians/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/degreesToRadians/ type: - resolvesToDouble - resolvesToDecimal @@ -17,14 +17,28 @@ arguments: By default $degreesToRadians returns values as a double. $degreesToRadians can also return values as a 128-bit decimal as long as the resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/degreesToRadians/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/degreesToRadians/#example pipeline: - $addFields: angle_a_rad: - $degreesToRadians: '$angle_a' + $degreesToRadians: $angle_a angle_b_rad: - $degreesToRadians: '$angle_b' + $degreesToRadians: $angle_b angle_c_rad: - $degreesToRadians: '$angle_c' + $degreesToRadians: $angle_c + schema: + TestCollection: + angle_a: + types: + - + bsonType: Decimal128 + angle_b: + types: + - + bsonType: Decimal128 + angle_c: + types: + - + bsonType: Decimal128 diff --git a/generator/config/expression/divide.yaml b/generator/config/expression/divide.yaml index 3b69389d8..4746cfd61 100644 --- a/generator/config/expression/divide.yaml +++ b/generator/config/expression/divide.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $divide -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/ type: - resolvesToDouble encode: array @@ -19,13 +19,31 @@ arguments: - resolvesToNumber tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/#examples pipeline: - $project: city: 1 workdays: $divide: - - '$hours' + - $hours - 8 + schema: + conferencePlanning: + _id: + types: + - + bsonType: Number + city: + types: + - + bsonType: String + hours: + types: + - + bsonType: Number + tasks: + types: + - + bsonType: Number diff --git a/generator/config/expression/eq.yaml b/generator/config/expression/eq.yaml index 009280ba1..c6e89cada 100644 --- a/generator/config/expression/eq.yaml +++ b/generator/config/expression/eq.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $eq -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/ type: - resolvesToBool encode: array @@ -17,8 +17,8 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/#example pipeline: - $project: @@ -26,6 +26,24 @@ tests: qty: 1 qtyEq250: $eq: - - '$qty' + - $qty - 250 _id: 0 + schema: + inventory: + _id: + types: + - + bsonType: Number + item: + types: + - + bsonType: String + description: + types: + - + bsonType: String + qty: + types: + - + bsonType: Number diff --git a/generator/config/expression/exp.yaml b/generator/config/expression/exp.yaml index d1f6982a1..376ce2e4d 100644 --- a/generator/config/expression/exp.yaml +++ b/generator/config/expression/exp.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $exp -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/ type: - resolvesToDouble encode: single @@ -13,13 +13,27 @@ arguments: - resolvesToNumber tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/#example pipeline: - $project: effectiveRate: $subtract: - - $exp: '$interestRate' + $exp: $interestRate - 1 + schema: + accounts: + _id: + types: + - + bsonType: Number + interestRate: + types: + - + bsonType: Number + presentValue: + types: + - + bsonType: Number diff --git a/generator/config/expression/filter.yaml b/generator/config/expression/filter.yaml index 0b72f6d75..62580e9b5 100644 --- a/generator/config/expression/filter.yaml +++ b/generator/config/expression/filter.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $filter -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/ type: - resolvesToArray encode: object @@ -34,61 +34,226 @@ arguments: If the specified limit is greater than the number of matching array elements, $filter returns all matching array elements. If the limit is null, $filter returns all matching array elements. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#examples' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#examples pipeline: - $project: items: $filter: - input: '$items' - as: 'item' + input: $items + as: item cond: $gte: - - '$$item.price' + - $$item.price - 100 + schema: + sales: + _id: + types: + - + bsonType: Number + items: + types: + - + bsonType: Array + types: + - + bsonType: Document + fields: + item_id: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + price: + types: + - + bsonType: Number + name: + types: + - + bsonType: String - - name: 'Using the limit field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#using-the-limit-field' + name: Use the limit field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#use-the-limit-field pipeline: - $project: items: $filter: - input: '$items' + input: $items cond: $gte: - - '$$item.price' + - $$item.price - 100 - as: 'item' + as: item limit: 1 + schema: + sales: + _id: + types: + - + bsonType: Number + items: + types: + - + bsonType: Array + types: + - + bsonType: Document + fields: + item_id: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + price: + types: + - + bsonType: Number + name: + types: + - + bsonType: String - - name: 'limit as a Numeric Expression' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#limit-as-a-numeric-expression' + name: limit Greater than Possible Matches + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#limit-greater-than-possible-matches pipeline: - $project: items: $filter: - input: '$items' + input: $items cond: - $lte: - - '$$item.price' - - 150 - as: 'item' - limit: 2 + $gte: + - $$item.price + - 100 + as: item + limit: 5 + schema: + sales: + _id: + types: + - + bsonType: Number + items: + types: + - + bsonType: Array + types: + - + bsonType: Document + fields: + item_id: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + price: + types: + - + bsonType: Number + name: + types: + - + bsonType: String - - name: 'limit Greater than Possible Matches' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#limit-greater-than-possible-matches' + name: Filter Based on String Equality Match + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#filter-based-on-string-equality-match pipeline: - $project: items: $filter: - input: '$items' + input: $items + as: item cond: - $gte: - - '$$item.price' - - 100 - as: 'item' - limit: 5 + $eq: + - $$item.name + - pen + schema: + sales: + _id: + types: + - + bsonType: Number + items: + types: + - + bsonType: Array + types: + - + bsonType: Document + fields: + item_id: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + price: + types: + - + bsonType: Number + name: + types: + - + bsonType: String + - + name: Filter Based on Regular Expression Match + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#filter-based-on-regular-expression-match + pipeline: + - + $project: + items: + $filter: + input: $items + as: item + cond: + $regexMatch: + input: $$item.name + regex: + pattern: /^p/ + options: '' + schema: + sales: + _id: + types: + - + bsonType: Number + items: + types: + - + bsonType: Array + types: + - + bsonType: Document + fields: + item_id: + types: + - + bsonType: Number + quantity: + types: + - + bsonType: Number + price: + types: + - + bsonType: Number + name: + types: + - + bsonType: String diff --git a/generator/config/expression/first.yaml b/generator/config/expression/first.yaml index 262d340c3..92752d666 100644 --- a/generator/config/expression/first.yaml +++ b/generator/config/expression/first.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $first -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/ type: - resolvesToAny encode: single @@ -13,9 +13,10 @@ arguments: - resolvesToArray tests: - - name: 'Use in $addFields Stage' + name: Use in $addFields Stage pipeline: - $addFields: firstItem: - $first: '$items' + $first: $items + schema: '// TODO: No docs reference found' diff --git a/generator/config/expression/firstN.yaml b/generator/config/expression/firstN.yaml index e914ff88c..3439ff02e 100644 --- a/generator/config/expression/firstN.yaml +++ b/generator/config/expression/firstN.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $firstN -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN-array-element/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN-array-element/ type: - resolvesToArray encode: object @@ -19,29 +19,32 @@ arguments: - resolvesToArray description: | An expression that resolves to the array from which to return n elements. - tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN-array-element/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN-array-element/#example pipeline: - $addFields: firstScores: $firstN: - n: 3 - input: '$score' + 'n': 3 + input: $score - - name: 'Using $firstN as an Aggregation Expression' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#using--firstn-as-an-aggregation-expression' + name: Using $firstN as an Aggregation Expression + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#using--firstn-as-an-aggregation-expression pipeline: - $documents: - - array: [10, 20, 30, 40] + array: + - 10 + - 20 + - 30 + - 40 - $project: firstThreeElements: $firstN: - input: '$array' - n: 3 + input: $array + 'n': 3 diff --git a/generator/config/expression/floor.yaml b/generator/config/expression/floor.yaml index 4c5856264..fe1c63074 100644 --- a/generator/config/expression/floor.yaml +++ b/generator/config/expression/floor.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $floor -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/ type: - resolvesToInt encode: single @@ -13,11 +13,11 @@ arguments: - resolvesToNumber tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/#example pipeline: - $project: value: 1 floorValue: - $floor: '$value' + $floor: $value diff --git a/generator/config/expression/function.yaml b/generator/config/expression/function.yaml index fa4dba8b5..adaa97d56 100644 --- a/generator/config/expression/function.yaml +++ b/generator/config/expression/function.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $function -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/ type: - resolvesToAny encode: object @@ -29,8 +29,8 @@ arguments: default: js tests: - - name: 'Usage Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#example-1--usage-example' + name: Usage Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#example-1--usage-example pipeline: - $addFields: @@ -42,8 +42,8 @@ tests: return hex_md5(name) == "15b0a220baa16331e8d80e15367677ad" } args: - - '$name' - lang: 'js' + - $name + lang: js message: $function: body: @@ -53,12 +53,12 @@ tests: return `Hello ${name}. Your total score is ${total}.` } args: - - '$name' - - '$scores' - lang: 'js' + - $name + - $scores + lang: js - - name: 'Alternative to $where' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#example-2--alternative-to--where' + name: Alternative to $where + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#example-2--alternative-to--where pipeline: - $match: @@ -70,5 +70,5 @@ tests: return hex_md5(name) == "15b0a220baa16331e8d80e15367677ad"; } args: - - '$name' - lang: 'js' + - $name + lang: js diff --git a/generator/config/expression/getField.yaml b/generator/config/expression/getField.yaml index 04b5d4ace..bbbf01141 100644 --- a/generator/config/expression/getField.yaml +++ b/generator/config/expression/getField.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $getField -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/ type: - resolvesToAny encode: object @@ -25,22 +25,20 @@ arguments: A valid expression that contains the field for which you want to return a value. input must resolve to an object, missing, null, or undefined. If omitted, defaults to the document currently being processed in the pipeline ($$CURRENT). tests: - - name: 'Query Fields that Contain Periods' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/#query-fields-that-contain-periods--.-' + name: Query Fields that Contain Periods + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/#query-fields-that-contain-periods--.- pipeline: - $match: $expr: $gt: - - # Example uses the short form, the builder always generates the verbose form - # $getField: 'price.usd' $getField: - field: 'price.usd' + field: price.usd - 200 - - name: 'Query Fields that Start with a Dollar Sign' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/#query-fields-that-start-with-a-dollar-sign----' + name: Query Fields that Start with a Dollar Sign + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/#query-fields-that-start-with-a-dollar-sign---- pipeline: - $match: @@ -48,14 +46,12 @@ tests: $gt: - $getField: - # Example uses the short form, the builder always generates the verbose form - # $literal: '$price' field: - $literal: '$price' + $literal: $price - 200 - - name: 'Query a Field in a Sub-document' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/#query-a-field-in-a-sub-document' + name: Query a Field in a Sub-document + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/#query-a-field-in-a-sub-document pipeline: - $match: @@ -64,6 +60,6 @@ tests: - $getField: field: - $literal: '$small' - input: '$quantity' + $literal: $small + input: $quantity - 20 diff --git a/generator/config/expression/gt.yaml b/generator/config/expression/gt.yaml index da3a35bb2..9767826a4 100644 --- a/generator/config/expression/gt.yaml +++ b/generator/config/expression/gt.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $gt -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/ type: - resolvesToBool encode: array @@ -14,11 +14,11 @@ arguments: - name: expression2 type: - - expression # lack of backreferral is an issue here + - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/#example pipeline: - $project: @@ -26,6 +26,6 @@ tests: qty: 1 qtyGt250: $gt: - - '$qty' + - $qty - 250 _id: 0 diff --git a/generator/config/expression/gte.yaml b/generator/config/expression/gte.yaml index 6b456daf6..af205a127 100644 --- a/generator/config/expression/gte.yaml +++ b/generator/config/expression/gte.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $gte -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/ type: - resolvesToBool encode: array @@ -17,8 +17,8 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/#example pipeline: - $project: @@ -26,6 +26,6 @@ tests: qty: 1 qtyGte250: $gte: - - '$qty' + - $qty - 250 _id: 0 diff --git a/generator/config/expression/hour.yaml b/generator/config/expression/hour.yaml index ebd62c3a0..deaa6c003 100644 --- a/generator/config/expression/hour.yaml +++ b/generator/config/expression/hour.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $hour -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/ type: - resolvesToInt encode: object @@ -24,13 +24,11 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/#example pipeline: - $project: hour: - # Example uses the short form, the builder always generates the verbose form - # $hour: '$date' $hour: - date: '$date' + date: $date diff --git a/generator/config/expression/ifNull.yaml b/generator/config/expression/ifNull.yaml index 9be8e9044..2fff0b313 100644 --- a/generator/config/expression/ifNull.yaml +++ b/generator/config/expression/ifNull.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $ifNull -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/ type: - resolvesToAny encode: single @@ -14,25 +14,25 @@ arguments: variadic: array tests: - - name: 'Single Input Expression' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/#single-input-expression' + name: Single Input Expression + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/#single-input-expression pipeline: - $project: item: 1 description: $ifNull: - - '$description' - - 'Unspecified' + - $description + - Unspecified - - name: 'Multiple Input Expressions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/#multiple-input-expressions' + name: Multiple Input Expressions + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/#multiple-input-expressions pipeline: - $project: item: 1 value: $ifNull: - - '$description' - - '$quantity' - - 'Unspecified' + - $description + - $quantity + - Unspecified diff --git a/generator/config/expression/in.yaml b/generator/config/expression/in.yaml index 7cef8c149..5f8a0a120 100644 --- a/generator/config/expression/in.yaml +++ b/generator/config/expression/in.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $in -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/ type: - resolvesToBool encode: array @@ -21,13 +21,13 @@ arguments: Any valid expression that resolves to an array. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/#example pipeline: - $project: - store location: '$location' + store location: $location has bananas: $in: - - 'bananas' - - '$in_stock' + - bananas + - $in_stock diff --git a/generator/config/expression/indexOfArray.yaml b/generator/config/expression/indexOfArray.yaml index 5840ee0fa..4e6aa8324 100644 --- a/generator/config/expression/indexOfArray.yaml +++ b/generator/config/expression/indexOfArray.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $indexOfArray -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfArray/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfArray/ type: - resolvesToInt encode: array @@ -37,12 +37,12 @@ arguments: If unspecified, the ending index position for the search is the end of the string. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfArray/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfArray/#example pipeline: - $project: index: $indexOfArray: - - '$items' + - $items - 2 diff --git a/generator/config/expression/indexOfBytes.yaml b/generator/config/expression/indexOfBytes.yaml index 7fe890891..20c100735 100644 --- a/generator/config/expression/indexOfBytes.yaml +++ b/generator/config/expression/indexOfBytes.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $indexOfBytes -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfBytes/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfBytes/ type: - resolvesToInt encode: array @@ -39,12 +39,12 @@ arguments: If unspecified, the ending index position for the search is the end of the string. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfBytes/#examples' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfBytes/#examples pipeline: - $project: byteLocation: $indexOfBytes: - - '$item' - - 'foo' + - $item + - foo diff --git a/generator/config/expression/indexOfCP.yaml b/generator/config/expression/indexOfCP.yaml index 88ed55ec6..226aa7384 100644 --- a/generator/config/expression/indexOfCP.yaml +++ b/generator/config/expression/indexOfCP.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $indexOfCP -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfCP/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfCP/ type: - resolvesToInt encode: array @@ -39,12 +39,12 @@ arguments: If unspecified, the ending index position for the search is the end of the string. tests: - - name: 'Examples' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfCP/#examples' + name: Examples + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfCP/#examples pipeline: - $project: cpLocation: $indexOfCP: - - '$item' - - 'foo' + - $item + - foo diff --git a/generator/config/expression/isArray.yaml b/generator/config/expression/isArray.yaml index b9a5d5cb5..d234804b9 100644 --- a/generator/config/expression/isArray.yaml +++ b/generator/config/expression/isArray.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $isArray -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/ type: - resolvesToBool encode: array @@ -13,8 +13,8 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/#example pipeline: - $project: @@ -22,15 +22,14 @@ tests: $cond: if: $and: - # Example uses the short form, the builder always generates the verbose form - $isArray: - - '$instock' + - $instock - $isArray: - - '$ordered' + - $ordered then: $concatArrays: - - '$instock' - - '$ordered' - else: 'One or more fields is not an array.' + - $instock + - $ordered + else: One or more fields is not an array. diff --git a/generator/config/expression/isNumber.yaml b/generator/config/expression/isNumber.yaml index 3bce99e99..edabe65ab 100644 --- a/generator/config/expression/isNumber.yaml +++ b/generator/config/expression/isNumber.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $isNumber -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isNumber/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isNumber/ type: - resolvesToBool encode: single @@ -15,61 +15,61 @@ arguments: - expression tests: - - name: 'Use $isNumber to Check if a Field is Numeric' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isNumber/#use--isnumber-to-check-if-a-field-is-numeric' + name: Use $isNumber to Check if a Field is Numeric + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isNumber/#use--isnumber-to-check-if-a-field-is-numeric pipeline: - $addFields: isNumber: - $isNumber: '$reading' + $isNumber: $reading hasType: - $type: '$reading' + $type: $reading - - name: 'Conditionally Modify Fields using $isNumber' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isNumber/#conditionally-modify-fields-using--isnumber' + name: Conditionally Modify Fields using $isNumber + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isNumber/#conditionally-modify-fields-using--isnumber pipeline: - $addFields: points: $cond: if: - $isNumber: '$grade' - then: '$grade' + $isNumber: $grade + then: $grade else: $switch: branches: - case: $eq: - - '$grade' - - 'A' + - $grade + - A then: 4 - case: $eq: - - '$grade' - - 'B' + - $grade + - B then: 3 - case: $eq: - - '$grade' - - 'C' + - $grade + - C then: 2 - case: $eq: - - '$grade' - - 'D' + - $grade + - D then: 1 - case: $eq: - - '$grade' - - 'F' + - $grade + - F then: 0 - $group: - _id: '$student_id' + _id: $student_id GPA: - $avg: '$points' + $avg: $points diff --git a/generator/config/expression/isoDayOfWeek.yaml b/generator/config/expression/isoDayOfWeek.yaml index 1956ff5c4..5b5ccd155 100644 --- a/generator/config/expression/isoDayOfWeek.yaml +++ b/generator/config/expression/isoDayOfWeek.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $isoDayOfWeek -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/ type: - resolvesToInt encode: object @@ -24,15 +24,13 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/#example pipeline: - $project: _id: 0 - name: '$name' + name: $name dayOfWeek: - # Example uses the short form, the builder always generates the verbose form - # $isoDayOfWeek: '$birthday' $isoDayOfWeek: - date: '$birthday' + date: $birthday diff --git a/generator/config/expression/isoWeek.yaml b/generator/config/expression/isoWeek.yaml index 2958a20c3..4399db7ec 100644 --- a/generator/config/expression/isoWeek.yaml +++ b/generator/config/expression/isoWeek.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $isoWeek -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/ type: - resolvesToInt encode: object @@ -24,15 +24,13 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/#example pipeline: - $project: _id: 0 - city: '$city' + city: $city weekNumber: - # Example uses the short form, the builder always generates the verbose form - # $isoWeek: '$date' $isoWeek: - date: '$date' + date: $date diff --git a/generator/config/expression/isoWeekYear.yaml b/generator/config/expression/isoWeekYear.yaml index 5dcefa7dd..d8769bff0 100644 --- a/generator/config/expression/isoWeekYear.yaml +++ b/generator/config/expression/isoWeekYear.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $isoWeekYear -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/ type: - resolvesToInt encode: object @@ -24,13 +24,11 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/#example pipeline: - $project: yearNumber: - # Example uses the short form, the builder always generates the verbose form - # $isoWeekYear: '$date' $isoWeekYear: - date: '$date' + date: $date diff --git a/generator/config/expression/last.yaml b/generator/config/expression/last.yaml index 2bf18dc7b..a7ab9ab9f 100644 --- a/generator/config/expression/last.yaml +++ b/generator/config/expression/last.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $last -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/ type: - resolvesToAny encode: single @@ -13,9 +13,9 @@ arguments: - resolvesToArray tests: - - name: 'Use in $addFields Stage' + name: Use in $addFields Stage pipeline: - $addFields: lastItem: - $last: '$items' + $last: $items diff --git a/generator/config/expression/lastN.yaml b/generator/config/expression/lastN.yaml index 0c29ad76e..d5fec386f 100644 --- a/generator/config/expression/lastN.yaml +++ b/generator/config/expression/lastN.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $lastN -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN-array-element/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN-array-element/ type: - resolvesToArray encode: object @@ -22,18 +22,17 @@ arguments: tests: - name: Example - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN-array-element/#example' + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN-array-element/#example pipeline: - $addFields: lastScores: $lastN: - n: 3 - input: '$score' - + 'n': 3 + input: $score - - name: 'Using $lastN as an Aggregation Expression' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#using--lastn-as-an-aggregation-expression' + name: Using $lastN as an Aggregation Expression + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#using--lastn-as-an-aggregation-expression pipeline: - $documents: @@ -47,5 +46,5 @@ tests: $project: lastThreeElements: $lastN: - input: '$array' - n: 3 + input: $array + 'n': 3 diff --git a/generator/config/expression/let.yaml b/generator/config/expression/let.yaml index 7d3017282..0b37e6a6f 100644 --- a/generator/config/expression/let.yaml +++ b/generator/config/expression/let.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $let -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/ type: - resolvesToAny encode: object @@ -11,7 +11,7 @@ arguments: - name: vars type: - - object # of expression + - object description: | Assignment block for the variables accessible in the in expression. To assign a variable, specify a string for the variable name and assign a valid expression for the value. The variable assignments have no meaning outside the in expression, not even within the vars block itself. @@ -23,8 +23,8 @@ arguments: The expression to evaluate. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/#example pipeline: - $project: @@ -33,14 +33,14 @@ tests: vars: total: $add: - - '$price' - - '$tax' + - $price + - $tax discounted: $cond: - if: '$applyDiscount' + if: $applyDiscount then: 0.9 else: 1 in: $multiply: - - '$$total' - - '$$discounted' + - $$total + - $$discounted diff --git a/generator/config/expression/literal.yaml b/generator/config/expression/literal.yaml index dfae7bbb3..5e4da0ccc 100644 --- a/generator/config/expression/literal.yaml +++ b/generator/config/expression/literal.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $literal -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ type: - resolvesToAny encode: single diff --git a/generator/config/expression/ln.yaml b/generator/config/expression/ln.yaml index f7412aeb9..ce1a06287 100644 --- a/generator/config/expression/ln.yaml +++ b/generator/config/expression/ln.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $ln -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ln/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ln/ type: - resolvesToDouble encode: single @@ -16,11 +16,11 @@ arguments: Any valid expression as long as it resolves to a non-negative number. For more information on expressions, see Expressions. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ln/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ln/#example pipeline: - $project: - x: '$year' - y: - $ln: '$sales' + x: $year + 'y': + $ln: $sales diff --git a/generator/config/expression/log.yaml b/generator/config/expression/log.yaml index 462eb9492..513d7f47f 100644 --- a/generator/config/expression/log.yaml +++ b/generator/config/expression/log.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $log -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/ type: - resolvesToDouble encode: array @@ -21,8 +21,8 @@ arguments: Any valid expression as long as it resolves to a positive number greater than 1. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/#example pipeline: - $project: @@ -32,5 +32,5 @@ tests: - 1 - $log: - - '$int' + - $int - 2 diff --git a/generator/config/expression/log10.yaml b/generator/config/expression/log10.yaml index 77cab075a..c2234a922 100644 --- a/generator/config/expression/log10.yaml +++ b/generator/config/expression/log10.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $log10 -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/ type: - resolvesToDouble encode: single @@ -15,8 +15,8 @@ arguments: Any valid expression as long as it resolves to a non-negative number. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/#example pipeline: - $project: @@ -24,4 +24,4 @@ tests: $multiply: - -1 - - $log10: '$H3O' + $log10: $H3O diff --git a/generator/config/expression/lt.yaml b/generator/config/expression/lt.yaml index 4b7319b97..6122d5a8c 100644 --- a/generator/config/expression/lt.yaml +++ b/generator/config/expression/lt.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $lt -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/ type: - resolvesToBool encode: array @@ -17,8 +17,8 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/#example pipeline: - $project: @@ -26,6 +26,6 @@ tests: qty: 1 qtyLt250: $lt: - - '$qty' + - $qty - 250 _id: 0 diff --git a/generator/config/expression/lte.yaml b/generator/config/expression/lte.yaml index 91c7b1d88..204cf984f 100644 --- a/generator/config/expression/lte.yaml +++ b/generator/config/expression/lte.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $lte -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/ type: - resolvesToBool encode: array @@ -17,8 +17,8 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/#example pipeline: - $project: @@ -26,6 +26,6 @@ tests: qty: 1 qtyLte250: $lte: - - '$qty' + - $qty - 250 _id: 0 diff --git a/generator/config/expression/ltrim.yaml b/generator/config/expression/ltrim.yaml index 992b70616..09cfe396a 100644 --- a/generator/config/expression/ltrim.yaml +++ b/generator/config/expression/ltrim.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $ltrim -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ltrim/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ltrim/ type: - resolvesToString encode: object @@ -25,12 +25,12 @@ arguments: If unspecified, $ltrim removes whitespace characters, including the null character. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ltrim/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ltrim/#example pipeline: - $project: item: 1 description: $ltrim: - input: '$description' + input: $description diff --git a/generator/config/expression/map.yaml b/generator/config/expression/map.yaml index 11db40c24..1807a6202 100644 --- a/generator/config/expression/map.yaml +++ b/generator/config/expression/map.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $map -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/ type: - resolvesToArray encode: object @@ -28,49 +28,47 @@ arguments: An expression that is applied to each element of the input array. The expression references each element individually with the variable name specified in as. tests: - - name: 'Add to Each Element of an Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/#add-to-each-element-of-an-array' + name: Add to Each Element of an Array + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/#add-to-each-element-of-an-array pipeline: - $project: adjustedGrades: $map: - input: '$quizzes' - as: 'grade' + input: $quizzes + as: grade in: $add: - - '$$grade' + - $$grade - 2 - - name: 'Truncate Each Array Element' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/#truncate-each-array-element' + name: Truncate Each Array Element + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/#truncate-each-array-element pipeline: - $project: - city: '$city' + city: $city integerValues: $map: - input: '$distances' - as: 'decimalValue' + input: $distances + as: decimalValue in: - # Example uses the short form, the builder always generates the verbose form - # $trunc: '$$decimalValue' $trunc: - - '$$decimalValue' + - $$decimalValue - - name: 'Convert Celsius Temperatures to Fahrenheit' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/#convert-celsius-temperatures-to-fahrenheit' + name: Convert Celsius Temperatures to Fahrenheit + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/#convert-celsius-temperatures-to-fahrenheit pipeline: - $addFields: tempsF: $map: - input: '$tempsC' - as: 'tempInCelsius' + input: $tempsC + as: tempInCelsius in: $add: - $multiply: - - '$$tempInCelsius' + - $$tempInCelsius - 1.8 - 32 diff --git a/generator/config/expression/max.yaml b/generator/config/expression/max.yaml index b413679c5..1572e0b0b 100644 --- a/generator/config/expression/max.yaml +++ b/generator/config/expression/max.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $max -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/ type: - resolvesToAny encode: single @@ -15,21 +15,18 @@ arguments: variadic: array tests: - - name: 'Use in $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#use-in--project-stage' + name: Use in $project Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#use-in--project-stage pipeline: - $project: quizMax: - # Example uses the short form, the builder always generates the verbose form - # $max: '$quizzes' $max: - - '$quizzes' + - $quizzes labMax: - # $max: '$labs' $max: - - '$labs' + - $labs examMax: $max: - - '$final' - - '$midterm' + - $final + - $midterm diff --git a/generator/config/expression/maxN.yaml b/generator/config/expression/maxN.yaml index e0d9d243e..6ffcfaeaf 100644 --- a/generator/config/expression/maxN.yaml +++ b/generator/config/expression/maxN.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $maxN -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN-array-element/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN-array-element/ type: - resolvesToArray encode: object @@ -21,12 +21,12 @@ arguments: An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN-array-element/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN-array-element/#example pipeline: - $addFields: maxScores: $maxN: - n: 2 - input: '$score' + 'n': 2 + input: $score diff --git a/generator/config/expression/median.yaml b/generator/config/expression/median.yaml index 2aac26a1f..96fb6410e 100644 --- a/generator/config/expression/median.yaml +++ b/generator/config/expression/median.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $median -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/ type: - resolvesToDouble encode: object @@ -16,7 +16,7 @@ arguments: name: input type: - resolvesToNumber - - array # of number + - array description: | $median calculates the 50th percentile value of this data. input must be a field name or an expression that evaluates to a numeric type. If the expression cannot be converted to a numeric type, the $median calculation ignores it. - @@ -27,8 +27,8 @@ arguments: The method that mongod uses to calculate the 50th percentile value. The method must be 'approximate'. tests: - - name: 'Use $median in a $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/#use-operatorname-in-a--project-stage' + name: Use $median in a $project Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/#use-operatorname-in-a--project-stage pipeline: - $project: @@ -37,7 +37,7 @@ tests: testMedians: $median: input: - - '$test01' - - '$test02' - - '$test03' - method: 'approximate' + - $test01 + - $test02 + - $test03 + method: approximate diff --git a/generator/config/expression/mergeObjects.yaml b/generator/config/expression/mergeObjects.yaml index 928166852..a750af296 100644 --- a/generator/config/expression/mergeObjects.yaml +++ b/generator/config/expression/mergeObjects.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $mergeObjects -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/ type: - resolvesToObject encode: single @@ -16,24 +16,24 @@ arguments: Any valid expression that resolves to a document. tests: - - name: '$mergeObjects' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/#-mergeobjects' + name: $mergeObjects + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/#-mergeobjects pipeline: - $lookup: - from: 'items' - localField: 'item' - foreignField: 'item' - as: 'fromItems' + from: items + localField: item + foreignField: item + as: fromItems - $replaceRoot: newRoot: $mergeObjects: - $arrayElemAt: - - '$fromItems' + - $fromItems - 0 - - '$$ROOT' + - $$ROOT - $project: fromItems: 0 diff --git a/generator/config/expression/meta.yaml b/generator/config/expression/meta.yaml index 9a96f7aaf..6e43676af 100644 --- a/generator/config/expression/meta.yaml +++ b/generator/config/expression/meta.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $meta -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/ type: - resolvesToAny encode: single @@ -13,27 +13,27 @@ arguments: - string tests: - - name: 'textScore' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/#-meta---textscore-' + name: textScore + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/#-meta---textscore- pipeline: - $match: $text: - $search: 'cake' + $search: cake - $group: _id: - $meta: 'textScore' + $meta: textScore count: $sum: 1 - - name: 'indexKey' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/#-meta---indexkey-' + name: indexKey + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/#-meta---indexkey- pipeline: - $match: - type: 'apparel' + type: apparel - $addFields: idxKey: - $meta: 'indexKey' + $meta: indexKey diff --git a/generator/config/expression/millisecond.yaml b/generator/config/expression/millisecond.yaml index af1d26e75..e5269ae7f 100644 --- a/generator/config/expression/millisecond.yaml +++ b/generator/config/expression/millisecond.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $millisecond -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/ type: - resolvesToInt encode: object @@ -24,13 +24,11 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/#example pipeline: - $project: milliseconds: - # Example uses the short form, the builder always generates the verbose form - # $millisecond: '$date' $millisecond: - date: '$date' + date: $date diff --git a/generator/config/expression/min.yaml b/generator/config/expression/min.yaml index 1212fd4f7..86e354de5 100644 --- a/generator/config/expression/min.yaml +++ b/generator/config/expression/min.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $min -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/ type: - resolvesToAny encode: single @@ -15,21 +15,18 @@ arguments: variadic: array tests: - - name: 'Use in $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#use-in--project-stage' + name: Use in $project Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#use-in--project-stage pipeline: - $project: quizMin: - # Example uses the short form, the builder always generates the verbose form - # $min: '$quizzes' $min: - - '$quizzes' + - $quizzes labMin: - # $min: '$labs' $min: - - '$labs' + - $labs examMin: $min: - - '$final' - - '$midterm' + - $final + - $midterm diff --git a/generator/config/expression/minN.yaml b/generator/config/expression/minN.yaml index e7fa8cac1..a7e45716d 100644 --- a/generator/config/expression/minN.yaml +++ b/generator/config/expression/minN.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $minN -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN-array-element/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN-array-element/ type: - resolvesToArray encode: object @@ -21,12 +21,12 @@ arguments: An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN-array-element/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN-array-element/#example pipeline: - $addFields: minScores: $minN: - n: 2 - input: '$score' + 'n': 2 + input: $score diff --git a/generator/config/expression/minute.yaml b/generator/config/expression/minute.yaml index 109e87f6b..c553f341c 100644 --- a/generator/config/expression/minute.yaml +++ b/generator/config/expression/minute.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $minute -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/ type: - resolvesToInt encode: object @@ -24,13 +24,11 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/#example pipeline: - $project: minutes: - # Example uses the short form, the builder always generates the verbose form - # $minute: '$date' $minute: - date: '$date' + date: $date diff --git a/generator/config/expression/mod.yaml b/generator/config/expression/mod.yaml index 0ac48bd54..14a50bfc8 100644 --- a/generator/config/expression/mod.yaml +++ b/generator/config/expression/mod.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $mod -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/ type: - resolvesToInt encode: array @@ -19,12 +19,12 @@ arguments: - resolvesToNumber tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/#example pipeline: - $project: remainder: $mod: - - '$hours' - - '$tasks' + - $hours + - $tasks diff --git a/generator/config/expression/month.yaml b/generator/config/expression/month.yaml index 7bd383be9..c7af36659 100644 --- a/generator/config/expression/month.yaml +++ b/generator/config/expression/month.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $month -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/ type: - resolvesToInt encode: object @@ -24,13 +24,11 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/#example pipeline: - $project: month: - # Example uses the short form, the builder always generates the verbose form - # $month: '$date' $month: - date: '$date' + date: $date diff --git a/generator/config/expression/multiply.yaml b/generator/config/expression/multiply.yaml index 5a069cc8c..fd4cb7db3 100644 --- a/generator/config/expression/multiply.yaml +++ b/generator/config/expression/multiply.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $multiply -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/ type: - resolvesToDecimal encode: single @@ -17,8 +17,8 @@ arguments: Starting in MongoDB 6.1 you can optimize the $multiply operation. To improve performance, group references at the end of the argument list. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/#example pipeline: - $project: @@ -26,5 +26,5 @@ tests: item: 1 total: $multiply: - - '$price' - - '$quantity' + - $price + - $quantity diff --git a/generator/config/expression/ne.yaml b/generator/config/expression/ne.yaml index da92f1014..bd778e5e5 100644 --- a/generator/config/expression/ne.yaml +++ b/generator/config/expression/ne.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $ne -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/ type: - resolvesToBool encode: array @@ -17,8 +17,8 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/#example pipeline: - $project: @@ -26,6 +26,6 @@ tests: qty: 1 qtyNe250: $ne: - - '$qty' + - $qty - 250 _id: 0 diff --git a/generator/config/expression/not.yaml b/generator/config/expression/not.yaml index d4e4c90ea..d0693de82 100644 --- a/generator/config/expression/not.yaml +++ b/generator/config/expression/not.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $not -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/ type: - resolvesToBool encode: array @@ -14,8 +14,8 @@ arguments: - resolvesToBool tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/#example pipeline: - $project: @@ -24,5 +24,5 @@ tests: $not: - $gt: - - '$qty' + - $qty - 250 diff --git a/generator/config/expression/objectToArray.yaml b/generator/config/expression/objectToArray.yaml index 460977f33..6b271dc06 100644 --- a/generator/config/expression/objectToArray.yaml +++ b/generator/config/expression/objectToArray.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $objectToArray -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/ type: - resolvesToArray encode: single @@ -14,31 +14,28 @@ arguments: description: | Any valid expression as long as it resolves to a document object. $objectToArray applies to the top-level fields of its argument. If the argument is a document that itself contains embedded document fields, the $objectToArray does not recursively apply to the embedded document fields. tests: - # "$objectToArray and $arrayToObject Example" omitted as it's already in arrayToObject.yaml - - name: '$objectToArray Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/#-objecttoarray-example' + name: $objectToArray Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/#-objecttoarray-example pipeline: - $project: item: 1 dimensions: - $objectToArray: '$dimensions' + $objectToArray: $dimensions - - name: '$objectToArray to Sum Nested Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/#-objecttoarray-to-sum-nested-fields' + name: $objectToArray to Sum Nested Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/#-objecttoarray-to-sum-nested-fields pipeline: - $project: warehouses: - $objectToArray: '$instock' + $objectToArray: $instock - - # Example uses the short form, the builder always generates the verbose form - # $unwind: '$warehouses' $unwind: - path: '$warehouses' + path: $warehouses - $group: - _id: '$warehouses.k' + _id: $warehouses.k total: - $sum: '$warehouses.v' + $sum: $warehouses.v diff --git a/generator/config/expression/or.yaml b/generator/config/expression/or.yaml index 2bbce1910..173bb77f7 100644 --- a/generator/config/expression/or.yaml +++ b/generator/config/expression/or.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $or -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/ type: - resolvesToBool encode: single @@ -15,8 +15,8 @@ arguments: variadic: array tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/#example pipeline: - $project: @@ -25,9 +25,9 @@ tests: $or: - $gt: - - '$qty' + - $qty - 250 - $lt: - - '$qty' + - $qty - 200 diff --git a/generator/config/expression/percentile.yaml b/generator/config/expression/percentile.yaml index b19fc1904..671e5897b 100644 --- a/generator/config/expression/percentile.yaml +++ b/generator/config/expression/percentile.yaml @@ -1,8 +1,8 @@ # $schema: ../schema.json name: $percentile -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/ type: - - resolvesToArray # of scalar + - resolvesToArray encode: object description: | Returns an array of scalar values that correspond to specified percentile values. @@ -19,13 +19,13 @@ arguments: name: input type: - resolvesToNumber - - array # of number + - array description: | $percentile calculates the percentile values of this data. input must be a field name or an expression that evaluates to a numeric type. If the expression cannot be converted to a numeric type, the $percentile calculation ignores it. - name: p type: - - resolvesToArray # of resolvesToNumber + - resolvesToArray description: | $percentile calculates a percentile value for each element in p. The elements represent percentages and must evaluate to numeric values in the range 0.0 to 1.0, inclusive. $percentile returns results in the same order as the elements in p. @@ -37,8 +37,8 @@ arguments: The method that mongod uses to calculate the percentile value. The method must be 'approximate'. tests: - - name: 'Use $percentile in a $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/#use-operatorname-in-a--project-stage' + name: Use $percentile in a $project Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/#use-operatorname-in-a--project-stage pipeline: - $project: @@ -46,6 +46,11 @@ tests: studentId: 1 testPercentiles: $percentile: - input: ['$test01', '$test02', '$test03'] - p: [0.5, 0.95] - method: 'approximate' + input: + - $test01 + - $test02 + - $test03 + p: + - 0.5 + - 0.95 + method: approximate diff --git a/generator/config/expression/pow.yaml b/generator/config/expression/pow.yaml index afab7f875..14d182244 100644 --- a/generator/config/expression/pow.yaml +++ b/generator/config/expression/pow.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $pow -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/pow/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/pow/ type: - resolvesToNumber encode: array @@ -17,15 +17,14 @@ arguments: - resolvesToNumber tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/pow/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/pow/#example pipeline: - $project: variance: $pow: - - # Example uses the short form, the builder always generates the verbose form - # $stdDevPop: '$scores.score' - $stdDevPop: ['$scores.score'] + $stdDevPop: + - $scores.score - 2 diff --git a/generator/config/expression/radiansToDegrees.yaml b/generator/config/expression/radiansToDegrees.yaml index be4dd1e1d..1e360a304 100644 --- a/generator/config/expression/radiansToDegrees.yaml +++ b/generator/config/expression/radiansToDegrees.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $radiansToDegrees -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/ type: - resolvesToDouble - resolvesToDecimal @@ -14,14 +14,14 @@ arguments: - resolvesToNumber tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/#example pipeline: - $addFields: angle_a_deg: - $radiansToDegrees: '$angle_a' + $radiansToDegrees: $angle_a angle_b_deg: - $radiansToDegrees: '$angle_b' + $radiansToDegrees: $angle_b angle_c_deg: - $radiansToDegrees: '$angle_c' + $radiansToDegrees: $angle_c diff --git a/generator/config/expression/rand.yaml b/generator/config/expression/rand.yaml index a19f3163e..d7e2dd969 100644 --- a/generator/config/expression/rand.yaml +++ b/generator/config/expression/rand.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $rand -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/ type: - resolvesToDouble encode: object @@ -8,8 +8,8 @@ description: | Returns a random float between 0 and 1 tests: - - name: 'Generate Random Data Points' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/#generate-random-data-points' + name: Generate Random Data Points + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/#generate-random-data-points pipeline: - $set: @@ -21,15 +21,13 @@ tests: - $set: amount: - $floor: '$amount' + $floor: $amount - - # Example uses the short form, the builder always generates the verbose form - # $merge: 'donors' $merge: - into: 'donors' + into: donors - - name: 'Select Random Items From a Collection' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/#select-random-items-from-a-collection' + name: Select Random Items From a Collection + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/#select-random-items-from-a-collection pipeline: - $match: diff --git a/generator/config/expression/range.yaml b/generator/config/expression/range.yaml index 5c78d8898..053144bab 100644 --- a/generator/config/expression/range.yaml +++ b/generator/config/expression/range.yaml @@ -1,8 +1,8 @@ # $schema: ../schema.json name: $range -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/range/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/range/ type: - - resolvesToArray # of int + - resolvesToArray encode: array description: | Outputs an array containing a sequence of integers according to user-defined inputs. @@ -28,8 +28,8 @@ arguments: An integer that specifies the increment value. Can be any valid expression that resolves to a non-zero integer. Defaults to 1. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/range/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/range/#example pipeline: - $project: @@ -38,5 +38,5 @@ tests: Rest stops: $range: - 0 - - '$distance' + - $distance - 25 diff --git a/generator/config/expression/reduce.yaml b/generator/config/expression/reduce.yaml index bf51eabe3..a23ebef88 100644 --- a/generator/config/expression/reduce.yaml +++ b/generator/config/expression/reduce.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $reduce -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/ type: - resolvesToAny encode: object @@ -32,47 +32,46 @@ arguments: - this is the variable that refers to the element being processed. tests: - - name: 'Multiplication' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#multiplication' + name: Multiplication + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#multiplication pipeline: - $group: - _id: '$experimentId' + _id: $experimentId probabilityArr: - $push: '$probability' + $push: $probability - $project: description: 1 results: $reduce: - input: '$probabilityArr' + input: $probabilityArr initialValue: 1 in: $multiply: - - '$$value' - - '$$this' + - $$value + - $$this - - name: 'Discounted Merchandise' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#discounted-merchandise' + name: Discounted Merchandise + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#discounted-merchandise pipeline: - $project: discountedPrice: $reduce: - input: '$discounts' - initialValue: '$price' + input: $discounts + initialValue: $price in: $multiply: - - '$$value' + - $$value - $subtract: - 1 - - '$$this' + - $$this - - name: 'String Concatenation' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#string-concatenation' + name: String Concatenation + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#string-concatenation pipeline: - # Filter to return only non-empty arrays - $match: hobbies: @@ -82,53 +81,53 @@ tests: name: 1 bio: $reduce: - input: '$hobbies' + input: $hobbies initialValue: 'My hobbies include:' in: $concat: - - '$$value' + - $$value - $cond: if: $eq: - - '$$value' + - $$value - 'My hobbies include:' then: ' ' else: ', ' - - '$$this' + - $$this - - name: 'Array Concatenation' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#array-concatenation' + name: Array Concatenation + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#array-concatenation pipeline: - $project: collapsed: $reduce: - input: '$arr' + input: $arr initialValue: [] in: $concatArrays: - - '$$value' - - '$$this' + - $$value + - $$this - - name: 'Computing a Multiple Reductions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#computing-a-multiple-reductions' + name: Computing a Multiple Reductions + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#computing-a-multiple-reductions pipeline: - $project: results: $reduce: - input: '$arr' + input: $arr initialValue: [] in: collapsed: $concatArrays: - - '$$value.collapsed' - - '$$this' + - $$value.collapsed + - $$this firstValues: $concatArrays: - - '$$value.firstValues' + - $$value.firstValues - $slice: - - '$$this' + - $$this - 1 diff --git a/generator/config/expression/regexFind.yaml b/generator/config/expression/regexFind.yaml index d953a4ae6..32436a4b1 100644 --- a/generator/config/expression/regexFind.yaml +++ b/generator/config/expression/regexFind.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $regexFind -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/ type: - resolvesToObject encode: object @@ -28,39 +28,42 @@ arguments: optional: true tests: - - name: '$regexFind and Its Options' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/#-regexfind-and-its-options' + name: $regexFind and Its Options + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/#-regexfind-and-its-options pipeline: - $addFields: returnObject: $regexFind: - input: '$description' - regex: !bson_regex 'line' + input: $description + regex: + pattern: line + options: '' - - name: 'i Option' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/#i-option' + name: i Option + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/#i-option pipeline: - $addFields: returnObject: - # Specify i as part of the Regex type $regexFind: - input: '$description' - regex: !bson_regex ['line', 'i'] + input: $description + regex: + pattern: line + options: i - $addFields: returnObject: - # Specify i in the options field $regexFind: - input: '$description' - regex: 'line' - options: 'i' + input: $description + regex: line + options: i - $addFields: returnObject: - # Mix Regex type with options field $regexFind: - input: '$description' - regex: !bson_regex 'line' - options: 'i' + input: $description + regex: + pattern: line + options: '' + options: i diff --git a/generator/config/expression/regexFindAll.yaml b/generator/config/expression/regexFindAll.yaml index 6aea184d7..7db3a33f2 100644 --- a/generator/config/expression/regexFindAll.yaml +++ b/generator/config/expression/regexFindAll.yaml @@ -1,8 +1,8 @@ # $schema: ../schema.json name: $regexFindAll -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/ type: - - resolvesToArray # of object + - resolvesToArray encode: object description: | Applies a regular expression (regex) to a string and returns information on the all matched substrings. @@ -28,72 +28,79 @@ arguments: optional: true tests: - - name: '$regexFindAll and Its Options' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/#-regexfindall-and-its-options' + name: $regexFindAll and Its Options + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/#-regexfindall-and-its-options pipeline: - $addFields: returnObject: $regexFindAll: - input: '$description' - regex: !bson_regex 'line' + input: $description + regex: + pattern: line + options: '' - - name: 'i Option' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/#i-option' + name: i Option + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/#i-option pipeline: - $addFields: returnObject: - # Specify i as part of the regex type $regexFindAll: - input: '$description' - regex: !bson_regex ['line', 'i'] + input: $description + regex: + pattern: line + options: i - $addFields: returnObject: - # Specify i in the options field $regexFindAll: - input: '$description' - regex: 'line' - options: 'i' + input: $description + regex: line + options: i - $addFields: returnObject: - # Mix Regex type with options field $regexFindAll: - input: '$description' - regex: !bson_regex 'line' - options: 'i' + input: $description + regex: + pattern: line + options: '' + options: i - - name: 'Use $regexFindAll to Parse Email from String' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/#use--regexfindall-to-parse-email-from-string' + name: Use $regexFindAll to Parse Email from String + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/#use--regexfindall-to-parse-email-from-string pipeline: - $addFields: email: $regexFindAll: - input: '$comment' - regex: !bson_regex ['[a-z0-9_.+-]+@[a-z0-9_.+-]+\.[a-z0-9_.+-]+', 'i'] + input: $comment + regex: + pattern: '[a-z0-9_.+-]+@[a-z0-9_.+-]+\.[a-z0-9_.+-]+' + options: i - $set: - email: '$email.match' + email: $email.match - - name: 'Use Captured Groupings to Parse User Name' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/#use-captured-groupings-to-parse-user-name' + name: Use Captured Groupings to Parse User Name + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/#use-captured-groupings-to-parse-user-name pipeline: - $addFields: names: $regexFindAll: - input: '$comment' - regex: !bson_regex ['([a-z0-9_.+-]+)@[a-z0-9_.+-]+\.[a-z0-9_.+-]+', 'i'] + input: $comment + regex: + pattern: ([a-z0-9_.+-]+)@[a-z0-9_.+-]+\.[a-z0-9_.+-]+ + options: i - $set: names: $reduce: - input: '$names.captures' + input: $names.captures initialValue: [] in: $concatArrays: - - '$$value' - - '$$this' + - $$value + - $$this diff --git a/generator/config/expression/regexMatch.yaml b/generator/config/expression/regexMatch.yaml index 4ea9f0aab..ce204946c 100644 --- a/generator/config/expression/regexMatch.yaml +++ b/generator/config/expression/regexMatch.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $regexMatch -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/ type: - resolvesToBool encode: object @@ -28,45 +28,48 @@ arguments: optional: true tests: - - name: '$regexMatch and Its Options' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/#-regexmatch-and-its-options' + name: $regexMatch and Its Options + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/#-regexmatch-and-its-options pipeline: - $addFields: result: $regexMatch: - input: '$description' - regex: !bson_regex 'line' + input: $description + regex: + pattern: line + options: '' - - name: 'i Option' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/#i-option' + name: i Option + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/#i-option pipeline: - $addFields: result: - # Specify i as part of the Regex type $regexMatch: - input: '$description' - regex: !bson_regex ['line', 'i'] + input: $description + regex: + pattern: line + options: i - $addFields: result: - # Specify i in the options field $regexMatch: - input: '$description' - regex: 'line' - options: 'i' + input: $description + regex: line + options: i - $addFields: result: - # Mix Regex type with options field $regexMatch: - input: '$description' - regex: !bson_regex 'line' - options: 'i' + input: $description + regex: + pattern: line + options: '' + options: i - - name: 'Use $regexMatch to Check Email Address' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/#use--regexmatch-to-check-email-address' + name: Use $regexMatch to Check Email Address + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/#use--regexmatch-to-check-email-address pipeline: - $addFields: @@ -74,7 +77,9 @@ tests: $cond: if: $regexMatch: - input: '$comment' - regex: !bson_regex ['[a-z0-9_.+-]+@mongodb.com', 'i'] - then: 'Employee' - else: 'External' + input: $comment + regex: + pattern: '[a-z0-9_.+-]+@mongodb.com' + options: i + then: Employee + else: External diff --git a/generator/config/expression/replaceAll.yaml b/generator/config/expression/replaceAll.yaml index 74d479cb7..f21f1ffd1 100644 --- a/generator/config/expression/replaceAll.yaml +++ b/generator/config/expression/replaceAll.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $replaceAll -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceAll/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceAll/ type: - resolvesToString encode: object @@ -32,13 +32,13 @@ arguments: The string to use to replace all matched instances of find in input. Can be any valid expression that resolves to a string or a null. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceAll/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceAll/#example pipeline: - $project: item: $replaceAll: - input: '$item' - find: 'blue paint' - replacement: 'red paint' + input: $item + find: blue paint + replacement: red paint diff --git a/generator/config/expression/replaceOne.yaml b/generator/config/expression/replaceOne.yaml index 0962cc6c5..52d444820 100644 --- a/generator/config/expression/replaceOne.yaml +++ b/generator/config/expression/replaceOne.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $replaceOne -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceOne/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceOne/ type: - resolvesToString encode: object @@ -31,13 +31,13 @@ arguments: The string to use to replace all matched instances of find in input. Can be any valid expression that resolves to a string or a null. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceOne/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceOne/#example pipeline: - $project: item: $replaceOne: - input: '$item' - find: 'blue paint' - replacement: 'red paint' + input: $item + find: blue paint + replacement: red paint diff --git a/generator/config/expression/reverseArray.yaml b/generator/config/expression/reverseArray.yaml index 2cbe3f3cd..2fb3c4c67 100644 --- a/generator/config/expression/reverseArray.yaml +++ b/generator/config/expression/reverseArray.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $reverseArray -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/reverseArray/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reverseArray/ type: - resolvesToArray encode: single @@ -15,11 +15,11 @@ arguments: The argument can be any valid expression as long as it resolves to an array. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/reverseArray/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reverseArray/#example pipeline: - $project: name: 1 reverseFavorites: - $reverseArray: '$favorites' + $reverseArray: $favorites diff --git a/generator/config/expression/round.yaml b/generator/config/expression/round.yaml index 9bc6961c7..8c437e66f 100644 --- a/generator/config/expression/round.yaml +++ b/generator/config/expression/round.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $round -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/ type: - resolvesToInt - resolvesToDouble @@ -26,17 +26,17 @@ arguments: Can be any valid expression that resolves to an integer between -20 and 100, exclusive. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/#example pipeline: - $project: roundedValue: $round: - - '$value' + - $value - 1 - - name: 'Round Average Rating' + name: Round Average Rating pipeline: - $project: @@ -46,5 +46,5 @@ tests: $round: - $avg: - - '$averageRating' + - $averageRating - 2 diff --git a/generator/config/expression/rtrim.yaml b/generator/config/expression/rtrim.yaml index a9d1974db..9fc7fcf66 100644 --- a/generator/config/expression/rtrim.yaml +++ b/generator/config/expression/rtrim.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $rtrim -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/rtrim/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/rtrim/ type: - resolvesToString encode: object @@ -24,12 +24,12 @@ arguments: If unspecified, $ltrim removes whitespace characters, including the null character. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/rtrim/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/rtrim/#example pipeline: - $project: item: 1 description: $rtrim: - input: '$description' + input: $description diff --git a/generator/config/expression/second.yaml b/generator/config/expression/second.yaml index 83e7fd370..5cef3cf3e 100644 --- a/generator/config/expression/second.yaml +++ b/generator/config/expression/second.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $second -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/ type: - resolvesToInt encode: object @@ -24,13 +24,11 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/#example pipeline: - $project: seconds: - # Example uses the short form, the builder always generates the verbose form - # $second: '$date' $second: - date: '$date' + date: $date diff --git a/generator/config/expression/setDifference.yaml b/generator/config/expression/setDifference.yaml index 69f448cb7..2bedca948 100644 --- a/generator/config/expression/setDifference.yaml +++ b/generator/config/expression/setDifference.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $setDifference -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setDifference/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setDifference/ type: - resolvesToArray encode: array @@ -21,8 +21,8 @@ arguments: The arguments can be any valid expression as long as they each resolve to an array. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setDifference/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setDifference/#example pipeline: - $project: @@ -30,6 +30,6 @@ tests: flowerFieldB: 1 inBOnly: $setDifference: - - '$flowerFieldB' - - '$flowerFieldA' + - $flowerFieldB + - $flowerFieldA _id: 0 diff --git a/generator/config/expression/setEquals.yaml b/generator/config/expression/setEquals.yaml index 5194c9ae9..e5486b220 100644 --- a/generator/config/expression/setEquals.yaml +++ b/generator/config/expression/setEquals.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $setEquals -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setEquals/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setEquals/ type: - resolvesToBool encode: single @@ -14,8 +14,8 @@ arguments: variadic: array tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setEquals/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setEquals/#example pipeline: - $project: @@ -24,5 +24,5 @@ tests: cupcakes: 1 sameFlavors: $setEquals: - - '$cakes' - - '$cupcakes' + - $cakes + - $cupcakes diff --git a/generator/config/expression/setField.yaml b/generator/config/expression/setField.yaml index b53cf6584..76d48b800 100644 --- a/generator/config/expression/setField.yaml +++ b/generator/config/expression/setField.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $setField -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/ type: - resolvesToObject encode: object @@ -29,39 +29,35 @@ arguments: Set to $$REMOVE to remove field from the input document. tests: - - name: 'Add Fields that Contain Periods' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#add-fields-that-contain-periods--.-' + name: Add Fields that Contain Periods + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#add-fields-that-contain-periods--.- pipeline: - $replaceWith: $setField: - field: 'price.usd' - input: '$$ROOT' - value: '$price' + field: price.usd + input: $$ROOT + value: $price - - # Example uses the short form, the builder always generates the verbose form - # $unset: 'price' $unset: - - 'price' + - price - - name: 'Add Fields that Start with a Dollar Sign' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#add-fields-that-start-with-a-dollar-sign----' + name: Add Fields that Start with a Dollar Sign + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#add-fields-that-start-with-a-dollar-sign---- pipeline: - $replaceWith: $setField: field: - $literal: '$price' - input: '$$ROOT' - value: '$price' + $literal: $price + input: $$ROOT + value: $price - - # Example uses the short form, the builder always generates the verbose form - # $unset: 'price' $unset: - - 'price' + - price - - name: 'Update Fields that Contain Periods' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#update-fields-that-contain-periods--.-' + name: Update Fields that Contain Periods + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#update-fields-that-contain-periods--.- pipeline: - $match: @@ -69,12 +65,12 @@ tests: - $replaceWith: $setField: - field: 'price.usd' - input: '$$ROOT' + field: price.usd + input: $$ROOT value: 49.99 - - name: 'Update Fields that Start with a Dollar Sign' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#update-fields-that-start-with-a-dollar-sign----' + name: Update Fields that Start with a Dollar Sign + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#update-fields-that-start-with-a-dollar-sign---- pipeline: - $match: @@ -83,27 +79,27 @@ tests: $replaceWith: $setField: field: - $literal: '$price' - input: '$$ROOT' + $literal: $price + input: $$ROOT value: 49.99 - - name: 'Remove Fields that Contain Periods' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#remove-fields-that-contain-periods--.-' + name: Remove Fields that Contain Periods + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#remove-fields-that-contain-periods--.- pipeline: - $replaceWith: $setField: - field: 'price.usd' - input: '$$ROOT' - value: '$$REMOVE' + field: price.usd + input: $$ROOT + value: $$REMOVE - - name: 'Remove Fields that Start with a Dollar Sign' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#remove-fields-that-start-with-a-dollar-sign----' + name: Remove Fields that Start with a Dollar Sign + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#remove-fields-that-start-with-a-dollar-sign---- pipeline: - $replaceWith: $setField: field: - $literal: '$price' - input: '$$ROOT' - value: '$$REMOVE' + $literal: $price + input: $$ROOT + value: $$REMOVE diff --git a/generator/config/expression/setIntersection.yaml b/generator/config/expression/setIntersection.yaml index 8f03651d5..5f75d23e2 100644 --- a/generator/config/expression/setIntersection.yaml +++ b/generator/config/expression/setIntersection.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $setIntersection -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/ type: - resolvesToArray encode: single @@ -14,8 +14,8 @@ arguments: variadic: array tests: - - name: 'Elements Array Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/#elements-array-example' + name: Elements Array Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/#elements-array-example pipeline: - $project: @@ -23,22 +23,21 @@ tests: flowerFieldB: 1 commonToBoth: $setIntersection: - - '$flowerFieldA' - - '$flowerFieldB' + - $flowerFieldA + - $flowerFieldB _id: 0 - - name: 'Retrieve Documents for Roles Granted to the Current User' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/#retrieve-documents-for-roles-granted-to-the-current-user' + name: Retrieve Documents for Roles Granted to the Current User + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/#retrieve-documents-for-roles-granted-to-the-current-user pipeline: - $match: $expr: $not: - # the example doesn't use an array inside $not, but the documentation say it is necessary - $eq: - $setIntersection: - - '$allowedRoles' - - '$$USER_ROLES.role' + - $allowedRoles + - $$USER_ROLES.role - [] diff --git a/generator/config/expression/setIsSubset.yaml b/generator/config/expression/setIsSubset.yaml index fe7c9ed02..9cacade87 100644 --- a/generator/config/expression/setIsSubset.yaml +++ b/generator/config/expression/setIsSubset.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $setIsSubset -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIsSubset/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIsSubset/ type: - resolvesToBool encode: array @@ -17,8 +17,8 @@ arguments: - resolvesToArray tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIsSubset/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIsSubset/#example pipeline: - $project: @@ -26,7 +26,6 @@ tests: flowerFieldB: 1 AisSubset: $setIsSubset: - - '$flowerFieldA' - - '$flowerFieldB' + - $flowerFieldA + - $flowerFieldB _id: 0 - diff --git a/generator/config/expression/setUnion.yaml b/generator/config/expression/setUnion.yaml index 2cfca3e16..b92d0193b 100644 --- a/generator/config/expression/setUnion.yaml +++ b/generator/config/expression/setUnion.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $setUnion -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/ type: - resolvesToArray encode: single @@ -14,8 +14,8 @@ arguments: variadic: array tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/#example pipeline: - $project: @@ -23,6 +23,6 @@ tests: flowerFieldB: 1 allValues: $setUnion: - - '$flowerFieldA' - - '$flowerFieldB' + - $flowerFieldA + - $flowerFieldB _id: 0 diff --git a/generator/config/expression/sin.yaml b/generator/config/expression/sin.yaml index fe02b4f28..60a15c425 100644 --- a/generator/config/expression/sin.yaml +++ b/generator/config/expression/sin.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $sin -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sin/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sin/ type: - resolvesToDouble - resolvesToDecimal @@ -17,8 +17,8 @@ arguments: By default $sin returns values as a double. $sin can also return values as a 128-bit decimal as long as the expression resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sin/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sin/#example pipeline: - $addFields: @@ -26,5 +26,5 @@ tests: $multiply: - $sin: - $degreesToRadians: '$angle_a' - - '$hypotenuse' + $degreesToRadians: $angle_a + - $hypotenuse diff --git a/generator/config/expression/sinh.yaml b/generator/config/expression/sinh.yaml index a5b446add..ea391e6b1 100644 --- a/generator/config/expression/sinh.yaml +++ b/generator/config/expression/sinh.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $sinh -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sinh/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sinh/ type: - resolvesToDouble - resolvesToDecimal @@ -17,11 +17,11 @@ arguments: By default $sinh returns values as a double. $sinh can also return values as a 128-bit decimal if the expression resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sinh/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sinh/#example pipeline: - $addFields: sinh_output: $sinh: - $degreesToRadians: '$angle' + $degreesToRadians: $angle diff --git a/generator/config/expression/size.yaml b/generator/config/expression/size.yaml index ce4fe775e..c526e09e8 100644 --- a/generator/config/expression/size.yaml +++ b/generator/config/expression/size.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $size -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/size/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/size/ type: - resolvesToInt encode: single @@ -15,8 +15,8 @@ arguments: The argument for $size can be any expression as long as it resolves to an array. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/size/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/size/#example pipeline: - $project: @@ -24,10 +24,8 @@ tests: numberOfColors: $cond: if: - # Example uses the short form, the builder always generates the verbose form - # $isArray: '$colors' $isArray: - - '$colors' + - $colors then: - $size: '$colors' - else: 'NA' + $size: $colors + else: NA diff --git a/generator/config/expression/slice.yaml b/generator/config/expression/slice.yaml index 22cc287e1..982857121 100644 --- a/generator/config/expression/slice.yaml +++ b/generator/config/expression/slice.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $slice -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/slice/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/slice/ type: - resolvesToArray encode: array @@ -23,7 +23,7 @@ arguments: If positive, $slice determines the starting position from the start of the array. If position is greater than the number of elements, the $slice returns an empty array. If negative, $slice determines the starting position from the end of the array. If the absolute value of the is greater than the number of elements, the starting position is the start of the array. - - name: "n" + name: 'n' type: - resolvesToInt description: | @@ -32,13 +32,13 @@ arguments: If negative, $slice returns up to the last n elements in the array. n cannot resolve to a negative number if is specified. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/slice/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/slice/#example pipeline: - $project: name: 1 threeFavorites: $slice: - - '$favorites' + - $favorites - 3 diff --git a/generator/config/expression/sortArray.yaml b/generator/config/expression/sortArray.yaml index d558f2233..19bfb0f53 100644 --- a/generator/config/expression/sortArray.yaml +++ b/generator/config/expression/sortArray.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $sortArray -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/ type: - resolvesToArray encode: object @@ -25,45 +25,45 @@ arguments: The document specifies a sort ordering. tests: - - name: 'Sort on a Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-on-a-field' + name: Sort on a Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-on-a-field pipeline: - $project: _id: 0 result: $sortArray: - input: '$team' + input: $team sortBy: name: 1 - - name: 'Sort on a Subfield' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-on-a-subfield' + name: Sort on a Subfield + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-on-a-subfield pipeline: - $project: _id: 0 result: $sortArray: - input: '$team' + input: $team sortBy: address.city: -1 - - name: 'Sort on Multiple Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-on-multiple-fields' + name: Sort on Multiple Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-on-multiple-fields pipeline: - $project: _id: 0 result: $sortArray: - input: '$team' + input: $team sortBy: age: -1 name: 1 - - name: 'Sort an Array of Integers' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-an-array-of-integers' + name: Sort an Array of Integers + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-an-array-of-integers pipeline: - $project: @@ -79,8 +79,8 @@ tests: - 5 sortBy: 1 - - name: 'Sort on Mixed Type Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-on-mixed-type-fields' + name: Sort on Mixed Type Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-on-mixed-type-fields pipeline: - $project: @@ -91,18 +91,19 @@ tests: - 20 - 4 - - a: 'Free' + a: Free - 6 - 21 - 5 - - 'Gratis' + - Gratis - - a: ~ + a: null - a: sale: true price: 19 - - !bson_decimal128 '10.23' - - a: 'On sale' + bytes: !!binary AQAAAAAAAAAAAAAAAABAMA== + - + a: On sale sortBy: 1 diff --git a/generator/config/expression/split.yaml b/generator/config/expression/split.yaml index 1c6169910..0cd63fd40 100644 --- a/generator/config/expression/split.yaml +++ b/generator/config/expression/split.yaml @@ -1,8 +1,8 @@ # $schema: ../schema.json name: $split -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/split/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/split/ type: - - resolvesToArray # of string + - resolvesToArray encode: array description: | Splits a string into substrings based on a delimiter. Returns an array of substrings. If the delimiter is not found within the string, returns an array containing the original string. @@ -21,28 +21,30 @@ arguments: The delimiter to use when splitting the string expression. delimiter can be any valid expression as long as it resolves to a string. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/split/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/split/#example pipeline: - $project: city_state: $split: - - '$city' + - $city - ', ' qty: 1 - $unwind: - path: '$city_state' + path: $city_state - $match: - city_state: !bson_regex '[A-Z]{2}' + city_state: + pattern: '[A-Z]{2}' + options: '' - $group: _id: - state: '$city_state' + state: $city_state total_qty: - $sum: '$qty' + $sum: $qty - $sort: total_qty: -1 diff --git a/generator/config/expression/sqrt.yaml b/generator/config/expression/sqrt.yaml index 52f5bb7c2..be98c997d 100644 --- a/generator/config/expression/sqrt.yaml +++ b/generator/config/expression/sqrt.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $sqrt -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sqrt/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sqrt/ type: - resolvesToDouble encode: single @@ -15,8 +15,8 @@ arguments: The argument can be any valid expression as long as it resolves to a non-negative number. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sqrt/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sqrt/#example pipeline: - $project: @@ -27,13 +27,13 @@ tests: $pow: - $subtract: - - '$p2.y' - - '$p1.y' + - $p2.y + - $p1.y - 2 - $pow: - $subtract: - - '$p2.x' - - '$p1.x' + - $p2.x + - $p1.x - 2 diff --git a/generator/config/expression/stdDevPop.yaml b/generator/config/expression/stdDevPop.yaml index 46641ebe8..1e5479666 100644 --- a/generator/config/expression/stdDevPop.yaml +++ b/generator/config/expression/stdDevPop.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $stdDevPop -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/ type: - resolvesToDouble encode: single @@ -16,12 +16,11 @@ arguments: variadic: array tests: - - name: 'Use in $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#use-in--project-stage' + name: Use in $project Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#use-in--project-stage pipeline: - $project: stdDev: - # Example uses the short form, the builder always generates the verbose form - # $stdDevPop: '$scores.score' - $stdDevPop: ['$scores.score'] + $stdDevPop: + - $scores.score diff --git a/generator/config/expression/stdDevSamp.yaml b/generator/config/expression/stdDevSamp.yaml index 84b35f52a..008110c7d 100644 --- a/generator/config/expression/stdDevSamp.yaml +++ b/generator/config/expression/stdDevSamp.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $stdDevSamp -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/ type: - resolvesToDouble encode: single diff --git a/generator/config/expression/strLenBytes.yaml b/generator/config/expression/strLenBytes.yaml index 301150d19..9f1fca514 100644 --- a/generator/config/expression/strLenBytes.yaml +++ b/generator/config/expression/strLenBytes.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $strLenBytes -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenBytes/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenBytes/ type: - resolvesToInt encode: single @@ -13,11 +13,11 @@ arguments: - resolvesToString tests: - - name: 'Single-Byte and Multibyte Character Set' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenBytes/#single-byte-and-multibyte-character-set' + name: Single-Byte and Multibyte Character Set + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenBytes/#single-byte-and-multibyte-character-set pipeline: - $project: name: 1 length: - $strLenBytes: '$name' + $strLenBytes: $name diff --git a/generator/config/expression/strLenCP.yaml b/generator/config/expression/strLenCP.yaml index b852c80ec..3c1ef1c9e 100644 --- a/generator/config/expression/strLenCP.yaml +++ b/generator/config/expression/strLenCP.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $strLenCP -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenCP/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenCP/ type: - resolvesToInt encode: single @@ -13,11 +13,11 @@ arguments: - resolvesToString tests: - - name: 'Single-Byte and Multibyte Character Set' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenBytes/#single-byte-and-multibyte-character-set' + name: Single-Byte and Multibyte Character Set + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenBytes/#single-byte-and-multibyte-character-set pipeline: - $project: name: 1 length: - $strLenCP: '$name' + $strLenCP: $name diff --git a/generator/config/expression/strcasecmp.yaml b/generator/config/expression/strcasecmp.yaml index 6775c44b1..d6254f939 100644 --- a/generator/config/expression/strcasecmp.yaml +++ b/generator/config/expression/strcasecmp.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $strcasecmp -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/strcasecmp/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/strcasecmp/ type: - resolvesToInt encode: array @@ -17,13 +17,13 @@ arguments: - resolvesToString tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/strcasecmp/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/strcasecmp/#example pipeline: - $project: item: 1 comparisonResult: $strcasecmp: - - '$quarter' - - '13q4' + - $quarter + - 13q4 diff --git a/generator/config/expression/substr.yaml b/generator/config/expression/substr.yaml index 6bcf6143f..d242baab5 100644 --- a/generator/config/expression/substr.yaml +++ b/generator/config/expression/substr.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $substr -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/substr/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/substr/ type: - resolvesToString encode: array @@ -25,19 +25,19 @@ arguments: If length is a negative number, $substr returns a substring that starts at the specified index and includes the rest of the string. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/substr/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/substr/#example pipeline: - $project: item: 1 yearSubstring: $substr: - - '$quarter' + - $quarter - 0 - 2 quarterSubtring: $substr: - - '$quarter' + - $quarter - 2 - -1 diff --git a/generator/config/expression/substrBytes.yaml b/generator/config/expression/substrBytes.yaml index fed7677c8..04ec2615e 100644 --- a/generator/config/expression/substrBytes.yaml +++ b/generator/config/expression/substrBytes.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $substrBytes -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/ type: - resolvesToString encode: array @@ -25,35 +25,35 @@ arguments: If length is a negative number, $substr returns a substring that starts at the specified index and includes the rest of the string. tests: - - name: 'Single-Byte Character Set' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/#single-byte-character-set' + name: Single-Byte Character Set + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/#single-byte-character-set pipeline: - $project: item: 1 yearSubstring: $substrBytes: - - '$quarter' + - $quarter - 0 - 2 quarterSubtring: $substrBytes: - - '$quarter' + - $quarter - 2 - $subtract: - - $strLenBytes: '$quarter' + $strLenBytes: $quarter - 2 - - name: 'Single-Byte and Multibyte Character Set' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/#single-byte-and-multibyte-character-set' + name: Single-Byte and Multibyte Character Set + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/#single-byte-and-multibyte-character-set pipeline: - $project: name: 1 menuCode: $substrBytes: - - '$name' + - $name - 0 - 3 diff --git a/generator/config/expression/substrCP.yaml b/generator/config/expression/substrCP.yaml index 843b2ca1a..c585067ef 100644 --- a/generator/config/expression/substrCP.yaml +++ b/generator/config/expression/substrCP.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $substrCP -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/ type: - resolvesToString encode: array @@ -25,35 +25,35 @@ arguments: If length is a negative number, $substr returns a substring that starts at the specified index and includes the rest of the string. tests: - - name: 'Single-Byte Character Set' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/#single-byte-character-set' + name: Single-Byte Character Set + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/#single-byte-character-set pipeline: - $project: item: 1 yearSubstring: $substrCP: - - '$quarter' + - $quarter - 0 - 2 quarterSubtring: $substrCP: - - '$quarter' + - $quarter - 2 - $subtract: - - $strLenCP: '$quarter' + $strLenCP: $quarter - 2 - - name: 'Single-Byte and Multibyte Character Set' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/#single-byte-and-multibyte-character-set' + name: Single-Byte and Multibyte Character Set + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/#single-byte-and-multibyte-character-set pipeline: - $project: name: 1 menuCode: $substrCP: - - '$name' + - $name - 0 - 3 diff --git a/generator/config/expression/subtract.yaml b/generator/config/expression/subtract.yaml index b6db65ac9..0275bbcd1 100644 --- a/generator/config/expression/subtract.yaml +++ b/generator/config/expression/subtract.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $subtract -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/ type: - resolvesToInt - resolvesToLong @@ -23,8 +23,8 @@ arguments: - resolvesToDate tests: - - name: 'Subtract Numbers' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#subtract-numbers' + name: Subtract Numbers + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#subtract-numbers pipeline: - $project: @@ -33,28 +33,28 @@ tests: $subtract: - $add: - - '$price' - - '$fee' - - '$discount' + - $price + - $fee + - $discount - - name: 'Subtract Two Dates' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#subtract-two-dates' + name: Subtract Two Dates + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#subtract-two-dates pipeline: - $project: item: 1 dateDifference: $subtract: - - '$$NOW' - - '$date' + - $$NOW + - $date - - name: 'Subtract Milliseconds from a Date' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#subtract-milliseconds-from-a-date' + name: Subtract Milliseconds from a Date + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#subtract-milliseconds-from-a-date pipeline: - $project: item: 1 dateDifference: $subtract: - - '$date' + - $date - 300000 diff --git a/generator/config/expression/sum.yaml b/generator/config/expression/sum.yaml index 25b323ab1..f0857c10a 100644 --- a/generator/config/expression/sum.yaml +++ b/generator/config/expression/sum.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $sum -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/ type: - resolvesToNumber encode: single @@ -16,21 +16,18 @@ arguments: variadic: array tests: - - name: 'Use in $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/#use-in--project-stage' + name: Use in $project Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/#use-in--project-stage pipeline: - $project: quizTotal: - # Example uses the short form, the builder always generates the verbose form - # $sum: '$quizzes' $sum: - - '$quizzes' + - $quizzes labTotal: - # $sum: '$labs' $sum: - - '$labs' + - $labs examTotal: $sum: - - '$final' - - '$midterm' + - $final + - $midterm diff --git a/generator/config/expression/switch.yaml b/generator/config/expression/switch.yaml index d668e3d94..2dd5ec120 100644 --- a/generator/config/expression/switch.yaml +++ b/generator/config/expression/switch.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $switch -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/ type: - resolvesToAny encode: object @@ -10,7 +10,7 @@ arguments: - name: branches type: - - array # of CaseOperator + - array description: | An array of control branch documents. Each branch is a document with the following fields: - case Can be any valid expression that resolves to a boolean. If the result is not a boolean, it is coerced to a boolean value. More information about how MongoDB evaluates expressions as either true or false can be found here. @@ -26,8 +26,8 @@ arguments: Although optional, if default is unspecified and no branch case evaluates to true, $switch returns an error. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/#example pipeline: - $project: @@ -39,32 +39,32 @@ tests: case: $gte: - - #$avg: '$scores' - $avg: [ '$scores' ] + $avg: + - $scores - 90 - then: 'Doing great!' + then: Doing great! - case: $and: - $gte: - - #$avg: '$scores' - $avg: [ '$scores' ] + $avg: + - $scores - 80 - $lt: - - #$avg: '$scores' - $avg: [ '$scores' ] + $avg: + - $scores - 90 - then: 'Doing pretty well.' + then: Doing pretty well. - case: $lt: - - #$avg: '$scores' - $avg: [ '$scores' ] + $avg: + - $scores - 80 - then: 'Needs improvement.' - default: 'No scores found.' + then: Needs improvement. + default: No scores found. diff --git a/generator/config/expression/tan.yaml b/generator/config/expression/tan.yaml index 17b11ee63..c23e1dd85 100644 --- a/generator/config/expression/tan.yaml +++ b/generator/config/expression/tan.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $tan -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/tan/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tan/ type: - resolvesToDouble - resolvesToDecimal @@ -17,8 +17,8 @@ arguments: By default $tan returns values as a double. $tan can also return values as a 128-bit decimal as long as the expression resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/tan/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tan/#example pipeline: - $addFields: @@ -26,5 +26,5 @@ tests: $multiply: - $tan: - $degreesToRadians: '$angle_a' - - '$side_a' + $degreesToRadians: $angle_a + - $side_a diff --git a/generator/config/expression/tanh.yaml b/generator/config/expression/tanh.yaml index 364589452..061b8e29f 100644 --- a/generator/config/expression/tanh.yaml +++ b/generator/config/expression/tanh.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $tanh -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/tanh/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tanh/ type: - resolvesToDouble - resolvesToDecimal @@ -17,11 +17,11 @@ arguments: By default $tanh returns values as a double. $tanh can also return values as a 128-bit decimal if the expression resolves to a 128-bit decimal value. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/tanh/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tanh/#example pipeline: - $addFields: tanh_output: $tanh: - $degreesToRadians: '$angle' + $degreesToRadians: $angle diff --git a/generator/config/expression/toBool.yaml b/generator/config/expression/toBool.yaml index 7f771ec8d..23afcbf51 100644 --- a/generator/config/expression/toBool.yaml +++ b/generator/config/expression/toBool.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $toBool -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toBool/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toBool/ type: - resolvesToBool encode: single @@ -14,8 +14,8 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toBool/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toBool/#example pipeline: - $addFields: @@ -25,17 +25,17 @@ tests: - case: $eq: - - '$shipped' + - $shipped - 'false' then: false - case: $eq: - - '$shipped' + - $shipped - '' then: false default: - $toBool: '$shipped' + $toBool: $shipped - $match: convertedShippedFlag: false diff --git a/generator/config/expression/toDate.yaml b/generator/config/expression/toDate.yaml index d9434a6bd..e299e2a9c 100644 --- a/generator/config/expression/toDate.yaml +++ b/generator/config/expression/toDate.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $toDate -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/ type: - resolvesToDate encode: single @@ -14,13 +14,13 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/#example pipeline: - $addFields: convertedDate: - $toDate: '$order_date' + $toDate: $order_date - $sort: convertedDate: 1 diff --git a/generator/config/expression/toDecimal.yaml b/generator/config/expression/toDecimal.yaml index 2f3588323..f9956919d 100644 --- a/generator/config/expression/toDecimal.yaml +++ b/generator/config/expression/toDecimal.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $toDecimal -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDecimal/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDecimal/ type: - resolvesToDecimal encode: single @@ -14,10 +14,10 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDecimal/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDecimal/#example pipeline: - $addFields: convertedPrice: - $toDecimal: '$price' + $toDecimal: $price diff --git a/generator/config/expression/toDouble.yaml b/generator/config/expression/toDouble.yaml index f34c36e9a..67098ab76 100644 --- a/generator/config/expression/toDouble.yaml +++ b/generator/config/expression/toDouble.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $toDouble -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDouble/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDouble/ type: - resolvesToDouble encode: single @@ -14,14 +14,14 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDouble/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDouble/#example pipeline: - $addFields: degrees: $toDouble: $substrBytes: - - '$temp' + - $temp - 0 - 4 diff --git a/generator/config/expression/toHashedIndexKey.yaml b/generator/config/expression/toHashedIndexKey.yaml index f5811f56d..ee1188739 100644 --- a/generator/config/expression/toHashedIndexKey.yaml +++ b/generator/config/expression/toHashedIndexKey.yaml @@ -1,28 +1,28 @@ # $schema: ../schema.json name: $toHashedIndexKey -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toHashedIndexKey/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toHashedIndexKey/ type: - - resolvesToLong + - resolvesToLong encode: single description: | - Computes and returns the hash value of the input expression using the same hash function that MongoDB uses to create a hashed index. A hash function maps a key or string to a fixed-size numeric value. + Computes and returns the hash value of the input expression using the same hash function that MongoDB uses to create a hashed index. A hash function maps a key or string to a fixed-size numeric value. arguments: - - - name: value - type: - - expression - description: | - key or string to hash + - + name: value + type: + - expression + description: | + key or string to hash tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toHashedIndexKey/#example' - pipeline: - - - $documents: - - - val: 'string to hash' - - - $addFields: - hashedVal: - $toHashedIndexKey: '$val' + - + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toHashedIndexKey/#example + pipeline: + - + $documents: + - + val: string to hash + - + $addFields: + hashedVal: + $toHashedIndexKey: $val diff --git a/generator/config/expression/toInt.yaml b/generator/config/expression/toInt.yaml index 2b0239955..802ee7920 100644 --- a/generator/config/expression/toInt.yaml +++ b/generator/config/expression/toInt.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $toInt -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/ type: - resolvesToInt encode: single @@ -14,10 +14,10 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/#example pipeline: - $addFields: convertedQty: - $toInt: '$qty' + $toInt: $qty diff --git a/generator/config/expression/toLong.yaml b/generator/config/expression/toLong.yaml index 3168ad9ff..bf9664339 100644 --- a/generator/config/expression/toLong.yaml +++ b/generator/config/expression/toLong.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $toLong -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/ type: - resolvesToLong encode: single @@ -14,13 +14,13 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/#example pipeline: - $addFields: convertedQty: - $toLong: '$qty' + $toLong: $qty - $sort: convertedQty: -1 diff --git a/generator/config/expression/toLower.yaml b/generator/config/expression/toLower.yaml index 0d6176672..b23f82e0e 100644 --- a/generator/config/expression/toLower.yaml +++ b/generator/config/expression/toLower.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $toLower -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLower/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLower/ type: - resolvesToString encode: single @@ -13,12 +13,12 @@ arguments: - resolvesToString tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLower/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLower/#example pipeline: - $project: item: - $toLower: '$item' + $toLower: $item description: - $toLower: '$description' + $toLower: $description diff --git a/generator/config/expression/toObjectId.yaml b/generator/config/expression/toObjectId.yaml index 803f7cafa..72261b31f 100644 --- a/generator/config/expression/toObjectId.yaml +++ b/generator/config/expression/toObjectId.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $toObjectId -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObjectId/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObjectId/ type: - resolvesToObjectId encode: single @@ -14,13 +14,13 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObjectId/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObjectId/#example pipeline: - $addFields: convertedId: - $toObjectId: '$_id' + $toObjectId: $_id - $sort: convertedId: -1 diff --git a/generator/config/expression/toString.yaml b/generator/config/expression/toString.yaml index 0fd068562..da5867bab 100644 --- a/generator/config/expression/toString.yaml +++ b/generator/config/expression/toString.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $toString -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/ type: - resolvesToString encode: single @@ -14,13 +14,13 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/#example pipeline: - $addFields: convertedZipCode: - $toString: '$zipcode' + $toString: $zipcode - $sort: convertedZipCode: 1 diff --git a/generator/config/expression/toUpper.yaml b/generator/config/expression/toUpper.yaml index c2c71e1bc..0045912db 100644 --- a/generator/config/expression/toUpper.yaml +++ b/generator/config/expression/toUpper.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $toUpper -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUpper/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUpper/ type: - resolvesToString encode: single @@ -13,12 +13,12 @@ arguments: - resolvesToString tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUpper/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUpper/#example pipeline: - $project: item: - $toUpper: '$item' + $toUpper: $item description: - $toUpper: '$description' + $toUpper: $description diff --git a/generator/config/expression/trim.yaml b/generator/config/expression/trim.yaml index d63423910..c908e5c3a 100644 --- a/generator/config/expression/trim.yaml +++ b/generator/config/expression/trim.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $trim -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/trim/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/trim/ type: - resolvesToString encode: object @@ -25,12 +25,12 @@ arguments: If unspecified, $ltrim removes whitespace characters, including the null character. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/trim/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/trim/#example pipeline: - $project: item: 1 description: $trim: - input: '$description' + input: $description diff --git a/generator/config/expression/trunc.yaml b/generator/config/expression/trunc.yaml index f930cf027..b83348491 100644 --- a/generator/config/expression/trunc.yaml +++ b/generator/config/expression/trunc.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $trunc -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/ type: - resolvesToString encode: array @@ -23,12 +23,12 @@ arguments: Can be any valid expression that resolves to an integer between -20 and 100, exclusive. e.g. -20 < place < 100. Defaults to 0. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/#example pipeline: - $project: truncatedValue: $trunc: - - '$value' + - $value - 1 diff --git a/generator/config/expression/tsIncrement.yaml b/generator/config/expression/tsIncrement.yaml index 9fded2143..2b3b0cc1c 100644 --- a/generator/config/expression/tsIncrement.yaml +++ b/generator/config/expression/tsIncrement.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $tsIncrement -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsIncrement/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsIncrement/ type: - resolvesToLong encode: single @@ -14,18 +14,18 @@ arguments: - resolvesToTimestamp tests: - - name: 'Obtain the Incrementing Ordinal from a Timestamp Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsIncrement/#obtain-the-incrementing-ordinal-from-a-timestamp-field' + name: Obtain the Incrementing Ordinal from a Timestamp Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsIncrement/#obtain-the-incrementing-ordinal-from-a-timestamp-field pipeline: - $project: _id: 0 saleTimestamp: 1 saleIncrement: - $tsIncrement: '$saleTimestamp' + $tsIncrement: $saleTimestamp - - name: 'Use $tsSecond in a Change Stream Cursor to Monitor Collection Changes' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/#use--tssecond-in-a-change-stream-cursor-to-monitor-collection-changes' + name: Use $tsSecond in a Change Stream Cursor to Monitor Collection Changes + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/#use--tssecond-in-a-change-stream-cursor-to-monitor-collection-changes pipeline: - $match: @@ -34,6 +34,6 @@ tests: - $mod: - - $tsIncrement: '$clusterTime' + $tsIncrement: $clusterTime - 2 - 0 diff --git a/generator/config/expression/tsSecond.yaml b/generator/config/expression/tsSecond.yaml index 20a84904b..768612dd6 100644 --- a/generator/config/expression/tsSecond.yaml +++ b/generator/config/expression/tsSecond.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $tsSecond -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/ type: - resolvesToLong encode: single @@ -14,20 +14,20 @@ arguments: - resolvesToTimestamp tests: - - name: 'Obtain the Number of Seconds from a Timestamp Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/#obtain-the-number-of-seconds-from-a-timestamp-field' + name: Obtain the Number of Seconds from a Timestamp Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/#obtain-the-number-of-seconds-from-a-timestamp-field pipeline: - $project: _id: 0 saleTimestamp: 1 saleSeconds: - $tsSecond: '$saleTimestamp' + $tsSecond: $saleTimestamp - - name: 'Use $tsSecond in a Change Stream Cursor to Monitor Collection Changes' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/#use--tssecond-in-a-change-stream-cursor-to-monitor-collection-changes' + name: Use $tsSecond in a Change Stream Cursor to Monitor Collection Changes + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/#use--tssecond-in-a-change-stream-cursor-to-monitor-collection-changes pipeline: - $addFields: clusterTimeSeconds: - $tsSecond: '$clusterTime' + $tsSecond: $clusterTime diff --git a/generator/config/expression/type.yaml b/generator/config/expression/type.yaml index c1f63db79..d905dce94 100644 --- a/generator/config/expression/type.yaml +++ b/generator/config/expression/type.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $type -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/type/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/type/ type: - resolvesToString encode: single @@ -13,10 +13,10 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/type/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/type/#example pipeline: - $project: a: - $type: '$a' + $type: $a diff --git a/generator/config/expression/unsetField.yaml b/generator/config/expression/unsetField.yaml index a4365a646..a1a1218fb 100644 --- a/generator/config/expression/unsetField.yaml +++ b/generator/config/expression/unsetField.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $unsetField -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/ type: - resolvesToObject encode: object @@ -22,38 +22,36 @@ arguments: Document that contains the field that you want to add or update. input must resolve to an object, missing, null, or undefined. tests: - - name: 'Remove Fields that Contain Periods' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/#remove-fields-that-contain-periods--.-' + name: Remove Fields that Contain Periods + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/#remove-fields-that-contain-periods--.- pipeline: - $replaceWith: $unsetField: - field: 'price.usd' - input: '$$ROOT' + field: price.usd + input: $$ROOT - - name: 'Remove Fields that Start with a Dollar Sign' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/#remove-fields-that-start-with-a-dollar-sign----' + name: Remove Fields that Start with a Dollar Sign + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/#remove-fields-that-start-with-a-dollar-sign---- pipeline: - $replaceWith: $unsetField: field: - $literal: '$price' - input: '$$ROOT' + $literal: $price + input: $$ROOT - - name: 'Remove A Subfield' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/#remove-a-subfield' + name: Remove A Subfield + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/#remove-a-subfield pipeline: - $replaceWith: $setField: - field: 'price' - input: '$$ROOT' + field: price + input: $$ROOT value: $unsetField: - field: 'euro' + field: euro input: - # Example uses the short form, the builder always generates the verbose form - # $getField: 'price' $getField: - field: 'price' + field: price diff --git a/generator/config/expression/week.yaml b/generator/config/expression/week.yaml index 6086f57ee..822ae09da 100644 --- a/generator/config/expression/week.yaml +++ b/generator/config/expression/week.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $week -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/ type: - resolvesToInt encode: object @@ -24,13 +24,11 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/#example pipeline: - $project: week: - # Example uses the short form, the builder always generates the verbose form - # $week: '$date' $week: - date: '$date' + date: $date diff --git a/generator/config/expression/year.yaml b/generator/config/expression/year.yaml index 3326e3495..90063da82 100644 --- a/generator/config/expression/year.yaml +++ b/generator/config/expression/year.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $year -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/ type: - resolvesToInt encode: object @@ -24,13 +24,11 @@ arguments: The timezone of the operation result. timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/#example pipeline: - $project: year: - # Example uses the short form, the builder always generates the verbose form - # $year: '$date' $year: - date: '$date' + date: $date diff --git a/generator/config/expression/zip.yaml b/generator/config/expression/zip.yaml index 76402dac5..e256c782d 100644 --- a/generator/config/expression/zip.yaml +++ b/generator/config/expression/zip.yaml @@ -1,8 +1,8 @@ # $schema: ../schema.json name: $zip -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/ type: - - resolvesToArray # of array + - resolvesToArray encode: object description: | Merge two arrays together. @@ -10,7 +10,7 @@ arguments: - name: inputs type: - - resolvesToArray # of array + - resolvesToArray description: | An array of expressions that resolve to arrays. The elements of these input arrays combine to form the arrays of the output array. If any of the inputs arrays resolves to a value of null or refers to a missing field, $zip returns null. @@ -34,8 +34,8 @@ arguments: If specifying a non-empty defaults, you must specify a default for each input array or else $zip will return an error. tests: - - name: 'Matrix Transposition' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/#matrix-transposition' + name: Matrix Transposition + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/#matrix-transposition pipeline: - $project: @@ -45,19 +45,19 @@ tests: inputs: - $arrayElemAt: - - '$matrix' + - $matrix - 0 - $arrayElemAt: - - '$matrix' + - $matrix - 1 - $arrayElemAt: - - '$matrix' + - $matrix - 2 - - name: 'Filtering and Preserving Indexes' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/#filtering-and-preserving-indexes' + name: Filtering and Preserving Indexes + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/#filtering-and-preserving-indexes pipeline: - $project: @@ -67,21 +67,21 @@ tests: input: $zip: inputs: - - '$pages' + - $pages - $range: - 0 - - $size: '$pages' - as: 'pageWithIndex' + $size: $pages + as: pageWithIndex cond: $let: vars: page: $arrayElemAt: - - '$$pageWithIndex' + - $$pageWithIndex - 0 in: $gte: - - '$$page.reviews' + - $$page.reviews - 1 diff --git a/generator/config/query/all.yaml b/generator/config/query/all.yaml index 868e205e2..1615951a7 100644 --- a/generator/config/query/all.yaml +++ b/generator/config/query/all.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $all -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/all/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/all/ type: - fieldQuery encode: single @@ -14,19 +14,19 @@ arguments: variadic: array tests: - - name: 'Use $all to Match Values' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/all/#use--all-to-match-values' + name: Use $all to Match Values + link: https://www.mongodb.com/docs/manual/reference/operator/query/all/#use--all-to-match-values pipeline: - $match: tags: $all: - - 'appliance' - - 'school' - - 'book' + - appliance + - school + - book - - name: 'Use $all with $elemMatch' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/all/#use--all-with--elemmatch' + name: Use $all with $elemMatch + link: https://www.mongodb.com/docs/manual/reference/operator/query/all/#use--all-with--elemmatch pipeline: - $match: @@ -34,10 +34,10 @@ tests: $all: - $elemMatch: - size: 'M' + size: M num: $gt: 50 - $elemMatch: num: 100 - color: 'green' + color: green diff --git a/generator/config/query/and.yaml b/generator/config/query/and.yaml index 74ebf506e..c55e83625 100644 --- a/generator/config/query/and.yaml +++ b/generator/config/query/and.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $and -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/and/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/and/ type: - query encode: single @@ -15,8 +15,8 @@ arguments: variadicMin: 1 tests: - - name: 'AND Queries With Multiple Expressions Specifying the Same Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/and/#and-queries-with-multiple-expressions-specifying-the-same-field' + name: AND Queries With Multiple Expressions Specifying the Same Field + link: https://www.mongodb.com/docs/manual/reference/operator/query/and/#and-queries-with-multiple-expressions-specifying-the-same-field pipeline: - $match: @@ -28,8 +28,8 @@ tests: price: $exists: true - - name: 'AND Queries With Multiple Expressions Specifying the Same Operator' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/and/#and-queries-with-multiple-expressions-specifying-the-same-operator' + name: AND Queries With Multiple Expressions Specifying the Same Operator + link: https://www.mongodb.com/docs/manual/reference/operator/query/and/#and-queries-with-multiple-expressions-specifying-the-same-operator pipeline: - $match: diff --git a/generator/config/query/bitsAllClear.yaml b/generator/config/query/bitsAllClear.yaml index 48e98037d..9047a474b 100644 --- a/generator/config/query/bitsAllClear.yaml +++ b/generator/config/query/bitsAllClear.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bitsAllClear -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/ type: - fieldQuery encode: single @@ -12,27 +12,34 @@ arguments: type: - int - binData - - array # of int + - array tests: - - name: 'Bit Position Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#bit-position-array' + name: Bit Position Array + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#bit-position-array pipeline: - $match: a: - $bitsAllClear: [1, 5] + $bitsAllClear: + - 1 + - 5 - - name: 'Integer Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#integer-bitmask' + name: Integer Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#integer-bitmask pipeline: - - $match: + - + $match: a: $bitsAllClear: 35 - - name: 'BinData Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#bindata-bitmask' + name: BinData Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#bindata-bitmask pipeline: - - $match: - a: - $bitsAllClear: !bson_binary 'IA==' + - + $match: + a: + $bitsAllClear: + sub_type: 0 + buffer: !!binary AAAA + position: 0 diff --git a/generator/config/query/bitsAllSet.yaml b/generator/config/query/bitsAllSet.yaml index 25e2c6eb8..c11c68660 100644 --- a/generator/config/query/bitsAllSet.yaml +++ b/generator/config/query/bitsAllSet.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bitsAllSet -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/ type: - fieldQuery encode: single @@ -12,27 +12,34 @@ arguments: type: - int - binData - - array # of int + - array tests: - - name: 'Bit Position Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#bit-position-array' + name: Bit Position Array + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#bit-position-array pipeline: - $match: a: - $bitsAllSet: [1, 5] + $bitsAllSet: + - 1 + - 5 - - name: 'Integer Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#integer-bitmask' + name: Integer Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#integer-bitmask pipeline: - - $match: - a: - $bitsAllSet: 50 + - + $match: + a: + $bitsAllSet: 50 - - name: 'BinData Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#bindata-bitmask' + name: BinData Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#bindata-bitmask pipeline: - - $match: - a: - $bitsAllSet: !bson_binary 'MA==' + - + $match: + a: + $bitsAllSet: + sub_type: 0 + buffer: !!binary AAAA + position: 0 diff --git a/generator/config/query/bitsAnyClear.yaml b/generator/config/query/bitsAnyClear.yaml index a41260998..c66614c79 100644 --- a/generator/config/query/bitsAnyClear.yaml +++ b/generator/config/query/bitsAnyClear.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bitsAnyClear -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/ type: - fieldQuery encode: single @@ -12,27 +12,34 @@ arguments: type: - int - binData - - array # of int + - array tests: - - name: 'Bit Position Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#bit-position-array' + name: Bit Position Array + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#bit-position-array pipeline: - $match: a: - $bitsAnyClear: [1, 5] + $bitsAnyClear: + - 1 + - 5 - - name: 'Integer Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#integer-bitmask' + name: Integer Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#integer-bitmask pipeline: - - $match: - a: - $bitsAnyClear: 35 + - + $match: + a: + $bitsAnyClear: 35 - - name: 'BinData Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#bindata-bitmask' + name: BinData Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#bindata-bitmask pipeline: - - $match: - a: - $bitsAnyClear: !bson_binary 'MA==' + - + $match: + a: + $bitsAnyClear: + sub_type: 0 + buffer: !!binary AAAA + position: 0 diff --git a/generator/config/query/bitsAnySet.yaml b/generator/config/query/bitsAnySet.yaml index 95aae908a..a88f31c46 100644 --- a/generator/config/query/bitsAnySet.yaml +++ b/generator/config/query/bitsAnySet.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bitsAnySet -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/ type: - fieldQuery encode: single @@ -12,27 +12,34 @@ arguments: type: - int - binData - - array # of int + - array tests: - - name: 'Bit Position Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#bit-position-array' + name: Bit Position Array + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#bit-position-array pipeline: - $match: a: - $bitsAnySet: [1, 5] + $bitsAnySet: + - 1 + - 5 - - name: 'Integer Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#integer-bitmask' + name: Integer Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#integer-bitmask pipeline: - - $match: - a: - $bitsAnySet: 35 + - + $match: + a: + $bitsAnySet: 35 - - name: 'BinData Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#bindata-bitmask' + name: BinData Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#bindata-bitmask pipeline: - - $match: - a: - $bitsAnySet: !bson_binary 'MA==' + - + $match: + a: + $bitsAnySet: + sub_type: 0 + buffer: !!binary AAAA + position: 0 diff --git a/generator/config/query/box.yaml b/generator/config/query/box.yaml index 14043c4ae..327a1e446 100644 --- a/generator/config/query/box.yaml +++ b/generator/config/query/box.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $box -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/box/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/box/ type: - geometry encode: single diff --git a/generator/config/query/center.yaml b/generator/config/query/center.yaml index c86215a52..17ad6af14 100644 --- a/generator/config/query/center.yaml +++ b/generator/config/query/center.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $center -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/center/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/center/ type: - geometry encode: single diff --git a/generator/config/query/centerSphere.yaml b/generator/config/query/centerSphere.yaml index e3677dade..2dc04732c 100644 --- a/generator/config/query/centerSphere.yaml +++ b/generator/config/query/centerSphere.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $centerSphere -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/centerSphere/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/centerSphere/ type: - geometry encode: single diff --git a/generator/config/query/comment.yaml b/generator/config/query/comment.yaml index 13a344613..dcd3f09d5 100644 --- a/generator/config/query/comment.yaml +++ b/generator/config/query/comment.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $comment -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/comment/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/comment/ type: - query encode: single @@ -13,19 +13,19 @@ arguments: - string tests: - - name: 'Attach a Comment to an Aggregation Expression' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/comment/#attach-a-comment-to-an-aggregation-expression' + name: Attach a Comment to an Aggregation Expression + link: https://www.mongodb.com/docs/manual/reference/operator/query/comment/#attach-a-comment-to-an-aggregation-expression pipeline: - $match: x: $gt: 0 - $comment: 'Don''t allow negative inputs.' + $comment: Don't allow negative inputs. - $group: _id: $mod: - - '$x' + - $x - 2 total: - $sum: '$x' + $sum: $x diff --git a/generator/config/query/elemMatch.yaml b/generator/config/query/elemMatch.yaml index 95db9572e..3a8845290 100644 --- a/generator/config/query/elemMatch.yaml +++ b/generator/config/query/elemMatch.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $elemMatch -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/ type: - fieldQuery encode: single @@ -14,8 +14,8 @@ arguments: - fieldQuery tests: - - name: 'Element Match' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/#element-match' + name: Element Match + link: https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/#element-match pipeline: - $match: @@ -24,28 +24,28 @@ tests: $gte: 80 $lt: 85 - - name: 'Array of Embedded Documents' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/#array-of-embedded-documents' + name: Array of Embedded Documents + link: https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/#array-of-embedded-documents pipeline: - $match: results: $elemMatch: - product: 'xyz' + product: xyz score: $gte: 8 - - name: 'Single Query Condition' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/#single-query-condition' + name: Single Query Condition + link: https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/#single-query-condition pipeline: - $match: results: $elemMatch: product: - $ne: 'xyz' + $ne: xyz - - name: 'Using $or with $elemMatch' + name: Using $or with $elemMatch pipeline: - $match: @@ -59,7 +59,7 @@ tests: score: $lt: 5 - - name: 'Single field operator' + name: Single field operator pipeline: - $match: diff --git a/generator/config/query/eq.yaml b/generator/config/query/eq.yaml index 5629114cc..0709021e2 100644 --- a/generator/config/query/eq.yaml +++ b/generator/config/query/eq.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $eq -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/eq/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/eq/ type: - fieldQuery encode: single @@ -13,49 +13,50 @@ arguments: - any tests: - - name: 'Equals a Specified Value' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/eq/#equals-a-specified-value' + name: Equals a Specified Value + link: https://www.mongodb.com/docs/manual/reference/operator/query/eq/#equals-a-specified-value pipeline: - $match: qty: $eq: 20 - - - name: 'Field in Embedded Document Equals a Value' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/eq/#field-in-embedded-document-equals-a-value' + name: Field in Embedded Document Equals a Value + link: https://www.mongodb.com/docs/manual/reference/operator/query/eq/#field-in-embedded-document-equals-a-value pipeline: - $match: - 'item.name': - $eq: 'ab' - + item.name: + $eq: ab - - name: 'Equals an Array Value' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/eq/#equals-an-array-value' + name: Equals an Array Value + link: https://www.mongodb.com/docs/manual/reference/operator/query/eq/#equals-an-array-value pipeline: - $match: tags: - $eq: ['A', 'B'] - + $eq: + - A + - B - - name: 'Regex Match Behaviour' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/eq/#regex-match-behaviour' + name: Regex Match Behaviour + link: https://www.mongodb.com/docs/manual/reference/operator/query/eq/#regex-match-behaviour pipeline: - $match: - company: 'MongoDB' + company: MongoDB - $match: company: - $eq: 'MongoDB' + $eq: MongoDB - $match: company: - !bson_regex '^MongoDB' + pattern: ^MongoDB + options: '' - $match: company: $eq: - !bson_regex '^MongoDB' + pattern: ^MongoDB + options: '' diff --git a/generator/config/query/exists.yaml b/generator/config/query/exists.yaml index 00d7ce2cb..6c6e69826 100644 --- a/generator/config/query/exists.yaml +++ b/generator/config/query/exists.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $exists -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/exists/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/exists/ type: - fieldQuery encode: single @@ -14,24 +14,26 @@ arguments: default: true tests: - - name: 'Exists and Not Equal To' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/exists/#exists-and-not-equal-to' + name: Exists and Not Equal To + link: https://www.mongodb.com/docs/manual/reference/operator/query/exists/#exists-and-not-equal-to pipeline: - $match: qty: $exists: true - $nin: [5, 15] + $nin: + - 5 + - 15 - - name: 'Null Values' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/exists/#null-values' + name: Null Values + link: https://www.mongodb.com/docs/manual/reference/operator/query/exists/#null-values pipeline: - $match: qty: $exists: true - - name: 'Missing Field' + name: Missing Field pipeline: - $match: diff --git a/generator/config/query/expr.yaml b/generator/config/query/expr.yaml index 320c84507..666c3ed26 100644 --- a/generator/config/query/expr.yaml +++ b/generator/config/query/expr.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $expr -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/expr/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/expr/ type: - query encode: single @@ -13,18 +13,18 @@ arguments: - expression tests: - - name: 'Compare Two Fields from A Single Document' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/expr/#compare-two-fields-from-a-single-document' + name: Compare Two Fields from A Single Document + link: https://www.mongodb.com/docs/manual/reference/operator/query/expr/#compare-two-fields-from-a-single-document pipeline: - $match: $expr: $gt: - - '$spent' - - '$budget' + - $spent + - $budget - - name: 'Using $expr With Conditional Statements' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/expr/#using--expr-with-conditional-statements' + name: Using $expr With Conditional Statements + link: https://www.mongodb.com/docs/manual/reference/operator/query/expr/#using--expr-with-conditional-statements pipeline: - $match: @@ -34,14 +34,14 @@ tests: $cond: if: $gte: - - '$qty' + - $qty - 100 then: $multiply: - - '$price' + - $price - 0.5 else: $multiply: - - '$price' + - $price - 0.75 - 5 diff --git a/generator/config/query/geoIntersects.yaml b/generator/config/query/geoIntersects.yaml index 4df3a43de..f3fd8d59c 100644 --- a/generator/config/query/geoIntersects.yaml +++ b/generator/config/query/geoIntersects.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $geoIntersects -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/geoIntersects/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/geoIntersects/ type: - fieldQuery encode: object @@ -14,40 +14,60 @@ arguments: - geometry tests: - - name: 'Intersects a Polygon' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/geoIntersects/#intersects-a-polygon' + name: Intersects a Polygon + link: https://www.mongodb.com/docs/manual/reference/operator/query/geoIntersects/#intersects-a-polygon pipeline: - $match: loc: $geoIntersects: $geometry: - type: 'Polygon' + type: Polygon coordinates: - - - [ 0, 0 ] - - [ 3, 6 ] - - [ 6, 1 ] - - [ 0, 0 ] + - + - 0 + - 0 + - + - 3 + - 6 + - + - 6 + - 1 + - + - 0 + - 0 - - name: 'Intersects a Big Polygon' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/geoIntersects/#intersects-a--big--polygon' + name: Intersects a Big Polygon + link: https://www.mongodb.com/docs/manual/reference/operator/query/geoIntersects/#intersects-a--big--polygon pipeline: - $match: loc: $geoIntersects: $geometry: - type: 'Polygon' + type: Polygon coordinates: - - - [ -100, 60 ] - - [ -100, 0 ] - - [ -100, -60 ] - - [ 100, -60 ] - - [ 100, 60 ] - - [ -100, 60 ] + - + - -100 + - 60 + - + - -100 + - 0 + - + - -100 + - -60 + - + - 100 + - -60 + - + - 100 + - 60 + - + - -100 + - 60 crs: - type: 'name' + type: name properties: - name: 'urn:x-mongodb:crs:strictwinding:EPSG:4326' + name: urn:x-mongodb:crs:strictwinding:EPSG:4326 diff --git a/generator/config/query/geoWithin.yaml b/generator/config/query/geoWithin.yaml index f9f6204d0..c2f81df88 100644 --- a/generator/config/query/geoWithin.yaml +++ b/generator/config/query/geoWithin.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $geoWithin -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/ type: - fieldQuery encode: object @@ -14,40 +14,60 @@ arguments: - geometry tests: - - name: 'Within a Polygon' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/#within-a-polygon' + name: Within a Polygon + link: https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/#within-a-polygon pipeline: - $match: loc: $geoWithin: $geometry: - type: 'Polygon' + type: Polygon coordinates: - - - [ 0, 0 ] - - [ 3, 6 ] - - [ 6, 1 ] - - [ 0, 0 ] + - + - 0 + - 0 + - + - 3 + - 6 + - + - 6 + - 1 + - + - 0 + - 0 - - name: 'Within a Big Polygon' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/#within-a--big--polygon' + name: Within a Big Polygon + link: https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/#within-a--big--polygon pipeline: - $match: loc: $geoWithin: $geometry: - type: 'Polygon' + type: Polygon coordinates: - - - [ -100, 60 ] - - [ -100, 0 ] - - [ -100, -60 ] - - [ 100, -60 ] - - [ 100, 60 ] - - [ -100, 60 ] + - + - -100 + - 60 + - + - -100 + - 0 + - + - -100 + - -60 + - + - 100 + - -60 + - + - 100 + - 60 + - + - -100 + - 60 crs: - type: 'name' + type: name properties: - name: 'urn:x-mongodb:crs:strictwinding:EPSG:4326' + name: urn:x-mongodb:crs:strictwinding:EPSG:4326 diff --git a/generator/config/query/geometry.yaml b/generator/config/query/geometry.yaml index 40b18dc99..2ab982cae 100644 --- a/generator/config/query/geometry.yaml +++ b/generator/config/query/geometry.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $geometry -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/geometry/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/geometry/ type: - geometry encode: object diff --git a/generator/config/query/gt.yaml b/generator/config/query/gt.yaml index 9914a5f34..921aead3e 100644 --- a/generator/config/query/gt.yaml +++ b/generator/config/query/gt.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $gt -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/gt/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/gt/ type: - fieldQuery encode: single @@ -13,8 +13,8 @@ arguments: - any tests: - - name: 'Match Document Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/gt/#match-document-fields' + name: Match Document Fields + link: https://www.mongodb.com/docs/manual/reference/operator/query/gt/#match-document-fields pipeline: - $match: diff --git a/generator/config/query/gte.yaml b/generator/config/query/gte.yaml index d8617a7c6..87b3c3351 100644 --- a/generator/config/query/gte.yaml +++ b/generator/config/query/gte.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $gte -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/gte/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/gte/ type: - fieldQuery encode: single @@ -13,8 +13,8 @@ arguments: - any tests: - - name: 'Match Document Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/gte/#match-document-fields' + name: Match Document Fields + link: https://www.mongodb.com/docs/manual/reference/operator/query/gte/#match-document-fields pipeline: - $match: diff --git a/generator/config/query/in.yaml b/generator/config/query/in.yaml index 67f069416..199a0c509 100644 --- a/generator/config/query/in.yaml +++ b/generator/config/query/in.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $in -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/in/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/in/ type: - fieldQuery encode: single @@ -10,23 +10,29 @@ arguments: - name: value type: - - array # of expression + - array tests: - - name: 'Use the $in Operator to Match Values in an Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/in/#use-the--in-operator-to-match-values' + name: Use the $in Operator to Match Values in an Array + link: https://www.mongodb.com/docs/manual/reference/operator/query/in/#use-the--in-operator-to-match-values pipeline: - $match: tags: - $in: ['home', 'school'] + $in: + - home + - school - - name: 'Use the $in Operator with a Regular Expression' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/in/#use-the--in-operator-with-a-regular-expression' + name: Use the $in Operator with a Regular Expression + link: https://www.mongodb.com/docs/manual/reference/operator/query/in/#use-the--in-operator-with-a-regular-expression pipeline: - $match: tags: $in: - - !bson_regex '^be' - - !bson_regex '^st' + - + pattern: ^be + options: '' + - + pattern: ^st + options: '' diff --git a/generator/config/query/jsonSchema.yaml b/generator/config/query/jsonSchema.yaml index 4c1dca6ad..6b15db8d9 100644 --- a/generator/config/query/jsonSchema.yaml +++ b/generator/config/query/jsonSchema.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $jsonSchema -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/jsonSchema/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/jsonSchema/ type: - query encode: single @@ -13,27 +13,27 @@ arguments: - object tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/jsonSchema/#syntax' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/query/jsonSchema/#syntax pipeline: - $match: $jsonSchema: required: - - 'name' - - 'major' - - 'gpa' - - 'address' + - name + - major + - gpa + - address properties: name: - bsonType: 'string' - description: 'must be a string and is required' + bsonType: string + description: must be a string and is required address: - bsonType: 'object' + bsonType: object required: - - 'zipcode' + - zipcode properties: street: - bsonType: 'string' + bsonType: string zipcode: - bsonType: 'string' + bsonType: string diff --git a/generator/config/query/lt.yaml b/generator/config/query/lt.yaml index f1c996ded..0d1d1debb 100644 --- a/generator/config/query/lt.yaml +++ b/generator/config/query/lt.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $lt -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/lt/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/lt/ type: - fieldQuery encode: single @@ -13,8 +13,8 @@ arguments: - any tests: - - name: 'Match Document Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/lt/#match-document-fields' + name: Match Document Fields + link: https://www.mongodb.com/docs/manual/reference/operator/query/lt/#match-document-fields pipeline: - $match: diff --git a/generator/config/query/lte.yaml b/generator/config/query/lte.yaml index e61d01b03..fd2b71103 100644 --- a/generator/config/query/lte.yaml +++ b/generator/config/query/lte.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $lte -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/lte/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/lte/ type: - fieldQuery encode: single @@ -13,8 +13,8 @@ arguments: - any tests: - - name: 'Match Document Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/lte/#match-document-fields' + name: Match Document Fields + link: https://www.mongodb.com/docs/manual/reference/operator/query/lte/#match-document-fields pipeline: - $match: diff --git a/generator/config/query/maxDistance.yaml b/generator/config/query/maxDistance.yaml index e95212d23..afe7b394b 100644 --- a/generator/config/query/maxDistance.yaml +++ b/generator/config/query/maxDistance.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $maxDistance -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/maxDistance/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/maxDistance/ type: - fieldQuery encode: single diff --git a/generator/config/query/minDistance.yaml b/generator/config/query/minDistance.yaml index fd467a96f..fbe3e1f92 100644 --- a/generator/config/query/minDistance.yaml +++ b/generator/config/query/minDistance.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $minDistance -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/minDistance/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/minDistance/ type: - fieldQuery encode: single diff --git a/generator/config/query/mod.yaml b/generator/config/query/mod.yaml index 04a187253..a13d02835 100644 --- a/generator/config/query/mod.yaml +++ b/generator/config/query/mod.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $mod -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/mod/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/mod/ type: - fieldQuery encode: array @@ -17,26 +17,34 @@ arguments: - number tests: - - name: 'Use $mod to Select Documents' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/mod/#use--mod-to-select-documents' + name: Use $mod to Select Documents + link: https://www.mongodb.com/docs/manual/reference/operator/query/mod/#use--mod-to-select-documents pipeline: - $match: qty: - $mod: [4, 0] + $mod: + - 4 + - 0 - - name: 'Floating Point Arguments' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/mod/#floating-point-arguments' + name: Floating Point Arguments + link: https://www.mongodb.com/docs/manual/reference/operator/query/mod/#floating-point-arguments pipeline: - $match: qty: - $mod: [4.0, 0] + $mod: + - 4 + - 0 - $match: qty: - $mod: [4.5, 0] + $mod: + - 4.5 + - 0 - $match: qty: - $mod: [4.99, 0] + $mod: + - 4.99 + - 0 diff --git a/generator/config/query/ne.yaml b/generator/config/query/ne.yaml index a1f5a046b..18d89cc4a 100644 --- a/generator/config/query/ne.yaml +++ b/generator/config/query/ne.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $ne -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/ne/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/ne/ type: - fieldQuery encode: single @@ -13,8 +13,8 @@ arguments: - any tests: - - name: 'Match Document Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/ne/#match-document-fields' + name: Match Document Fields + link: https://www.mongodb.com/docs/manual/reference/operator/query/ne/#match-document-fields pipeline: - $match: diff --git a/generator/config/query/near.yaml b/generator/config/query/near.yaml index 89d7f511f..b3353b6ac 100644 --- a/generator/config/query/near.yaml +++ b/generator/config/query/near.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $near -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/near/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/near/ type: - fieldQuery encode: object @@ -28,15 +28,15 @@ arguments: Distance in meters. Limits the results to those documents that are at least the specified distance from the center point. tests: - - name: 'Query on GeoJSON Data' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/near/#query-on-geojson-data' + name: Query on GeoJSON Data + link: https://www.mongodb.com/docs/manual/reference/operator/query/near/#query-on-geojson-data pipeline: - $match: location: $near: $geometry: - type: 'Point' + type: Point coordinates: - -73.9667 - 40.78 diff --git a/generator/config/query/nearSphere.yaml b/generator/config/query/nearSphere.yaml index 72e8e18e9..725a66f86 100644 --- a/generator/config/query/nearSphere.yaml +++ b/generator/config/query/nearSphere.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $nearSphere -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nearSphere/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/nearSphere/ type: - fieldQuery encode: object @@ -28,15 +28,17 @@ arguments: Distance in meters. Limits the results to those documents that are at least the specified distance from the center point. tests: - - name: 'Specify Center Point Using GeoJSON' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nearSphere/#specify-center-point-using-geojson' + name: Specify Center Point Using GeoJSON + link: https://www.mongodb.com/docs/manual/reference/operator/query/nearSphere/#specify-center-point-using-geojson pipeline: - $match: location: $nearSphere: $geometry: - type: 'Point' - coordinates: [-73.9667, 40.78] + type: Point + coordinates: + - -73.9667 + - 40.78 $minDistance: 1000 $maxDistance: 5000 diff --git a/generator/config/query/nin.yaml b/generator/config/query/nin.yaml index 4285e4fe7..7e30c9cc2 100644 --- a/generator/config/query/nin.yaml +++ b/generator/config/query/nin.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $nin -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nin/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/nin/ type: - fieldQuery encode: single @@ -10,21 +10,24 @@ arguments: - name: value type: - - array # of expression + - array tests: - - name: 'Select on Unmatching Documents' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nin/#select-on-unmatching-documents' + name: Select on Unmatching Documents + link: https://www.mongodb.com/docs/manual/reference/operator/query/nin/#select-on-unmatching-documents pipeline: - $match: quantity: - $nin: [5, 15] + $nin: + - 5 + - 15 - - name: 'Select on Elements Not in an Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nin/#select-on-elements-not-in-an-array' + name: Select on Elements Not in an Array + link: https://www.mongodb.com/docs/manual/reference/operator/query/nin/#select-on-elements-not-in-an-array pipeline: - $match: tags: - $nin: ['school'] + $nin: + - school diff --git a/generator/config/query/nor.yaml b/generator/config/query/nor.yaml index d1ad7159a..15a5b657d 100644 --- a/generator/config/query/nor.yaml +++ b/generator/config/query/nor.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $nor -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nor/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/nor/ type: - query encode: single @@ -15,8 +15,8 @@ arguments: variadicMin: 1 tests: - - name: 'Query with Two Expressions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-query-with-two-expressions' + name: Query with Two Expressions + link: https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-query-with-two-expressions pipeline: - $match: @@ -26,8 +26,8 @@ tests: - sale: true - - name: 'Additional Comparisons' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and-additional-comparisons' + name: Additional Comparisons + link: https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and-additional-comparisons pipeline: - $match: @@ -40,8 +40,8 @@ tests: - sale: true - - name: '$nor and $exists' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and--exists' + name: $nor and $exists + link: https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and--exists pipeline: - $match: diff --git a/generator/config/query/not.yaml b/generator/config/query/not.yaml index eb2b43cdb..246cc00f9 100644 --- a/generator/config/query/not.yaml +++ b/generator/config/query/not.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $not -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/not/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/not/ type: - fieldQuery encode: single @@ -13,8 +13,8 @@ arguments: - fieldQuery tests: - - name: 'Syntax' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/not/#syntax' + name: Syntax + link: https://www.mongodb.com/docs/manual/reference/operator/query/not/#syntax pipeline: - $match: @@ -22,10 +22,12 @@ tests: $not: $gt: 1.99 - - name: 'Regular Expressions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/not/#-not-and-regular-expressions' + name: Regular Expressions + link: https://www.mongodb.com/docs/manual/reference/operator/query/not/#-not-and-regular-expressions pipeline: - $match: price: - $not: !bson_regex '^p.*' + $not: + pattern: ^p.* + options: '' diff --git a/generator/config/query/or.yaml b/generator/config/query/or.yaml index ce2b7603c..2d56663d5 100644 --- a/generator/config/query/or.yaml +++ b/generator/config/query/or.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $or -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/or/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/or/ type: - query encode: single @@ -15,8 +15,8 @@ arguments: variadicMin: 1 tests: - - name: '$or Clauses' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/or/#-or-clauses-and-indexes' + name: $or Clauses + link: https://www.mongodb.com/docs/manual/reference/operator/query/or/#-or-clauses-and-indexes pipeline: - $match: @@ -26,10 +26,9 @@ tests: $lt: 20 - price: 10 - - - name: 'Error Handling' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/or/#error-handling' + name: Error Handling + link: https://www.mongodb.com/docs/manual/reference/operator/query/or/#error-handling pipeline: - $match: @@ -43,5 +42,5 @@ tests: - $divide: - 1 - - '$x' + - $x - 3 diff --git a/generator/config/query/polygon.yaml b/generator/config/query/polygon.yaml index 1a46f2bc4..227362f02 100644 --- a/generator/config/query/polygon.yaml +++ b/generator/config/query/polygon.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $polygon -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/polygon/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/polygon/ type: - geometry encode: single diff --git a/generator/config/query/rand.yaml b/generator/config/query/rand.yaml index 6773ae0d5..7f571dfbf 100644 --- a/generator/config/query/rand.yaml +++ b/generator/config/query/rand.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $rand -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/rand/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/rand/ type: - resolvesToDouble encode: object @@ -8,8 +8,8 @@ description: | Generates a random float between 0 and 1. tests: - - name: 'Select Random Items From a Collection' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/rand/#select-random-items-from-a-collection' + name: Select Random Items From a Collection + link: https://www.mongodb.com/docs/manual/reference/operator/query/rand/#select-random-items-from-a-collection pipeline: - $match: diff --git a/generator/config/query/regex.yaml b/generator/config/query/regex.yaml index c7e378ddd..a6ebf95be 100644 --- a/generator/config/query/regex.yaml +++ b/generator/config/query/regex.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $regex -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/regex/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/regex/ type: - fieldQuery encode: single @@ -11,23 +11,24 @@ arguments: name: regex type: - regex - tests: - - name: 'Perform a LIKE Match' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/regex/#perform-a-like-match' + name: Perform a LIKE Match + link: https://www.mongodb.com/docs/manual/reference/operator/query/regex/#perform-a-like-match pipeline: - $match: sku: $regex: - !bson_regex '789$' + pattern: 789$ + options: '' - - name: 'Perform Case-Insensitive Regular Expression Match' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/regex/#perform-case-insensitive-regular-expression-match' + name: Perform Case-Insensitive Regular Expression Match + link: https://www.mongodb.com/docs/manual/reference/operator/query/regex/#perform-case-insensitive-regular-expression-match pipeline: - $match: sku: $regex: - !bson_regex ['^ABC', 'i'] + pattern: ^ABC + options: i diff --git a/generator/config/query/sampleRate.yaml b/generator/config/query/sampleRate.yaml index 9995e2d8b..4b9252c87 100644 --- a/generator/config/query/sampleRate.yaml +++ b/generator/config/query/sampleRate.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $sampleRate -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sampleRate/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sampleRate/ type: - query encode: single @@ -16,11 +16,11 @@ arguments: For example, a sample rate of 0.33 selects roughly one document in three. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sampleRate/#examples' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sampleRate/#examples pipeline: - $match: $sampleRate: 0.33 - - $count: 'numMatches' + $count: numMatches diff --git a/generator/config/query/size.yaml b/generator/config/query/size.yaml index 629de4035..f95bd70f4 100644 --- a/generator/config/query/size.yaml +++ b/generator/config/query/size.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $size -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/size/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/size/ type: - fieldQuery encode: single @@ -13,8 +13,8 @@ arguments: - int tests: - - name: 'Query an Array by Array Length' - link: 'https://www.mongodb.com/docs/manual/tutorial/query-arrays/#query-an-array-by-array-length' + name: Query an Array by Array Length + link: https://www.mongodb.com/docs/manual/tutorial/query-arrays/#query-an-array-by-array-length pipeline: - $match: diff --git a/generator/config/query/text.yaml b/generator/config/query/text.yaml index 574ee4508..f5196b2fe 100644 --- a/generator/config/query/text.yaml +++ b/generator/config/query/text.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $text -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/text/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/text/ type: - query encode: object @@ -38,77 +38,77 @@ arguments: Text searches against earlier versions of the text index are inherently diacritic sensitive and cannot be diacritic insensitive. As such, the $diacriticSensitive option has no effect with earlier versions of the text index. tests: - - name: 'Search for a Single Word' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/text/#search-for-a-single-word' + name: Search for a Single Word + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#search-for-a-single-word pipeline: - $match: $text: - $search: 'coffee' + $search: coffee - - name: 'Match Any of the Search Terms' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/text/#search-for-a-single-word' + name: Match Any of the Search Terms + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#search-for-a-single-word pipeline: - $match: $text: - $search: 'bake coffee cake' + $search: bake coffee cake - - name: 'Search a Different Language' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/text/#search-a-different-language' + name: Search a Different Language + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#search-a-different-language pipeline: - $match: $text: - $search: 'leche' - $language: 'es' + $search: leche + $language: es - - name: 'Case and Diacritic Insensitive Search' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/text/#case-and-diacritic-insensitive-search' + name: Case and Diacritic Insensitive Search + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#case-and-diacritic-insensitive-search pipeline: - $match: $text: - $search: 'сы́рники CAFÉS' + $search: сы́рники CAFÉS - - name: 'Perform Case Sensitive Search' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/text/#perform-case-sensitive-search' + name: Perform Case Sensitive Search + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#perform-case-sensitive-search pipeline: - $match: $text: - $search: 'Coffee' + $search: Coffee $caseSensitive: true - $match: $text: - $search: '\"Café Con Leche\"' + $search: \"Café Con Leche\" $caseSensitive: true - - name: 'Diacritic Sensitive Search' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/text/#perform-case-sensitive-search' + name: Diacritic Sensitive Search + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#perform-case-sensitive-search pipeline: - $match: $text: - $search: 'CAFÉ' + $search: CAFÉ $diacriticSensitive: true - - name: 'Text Search Score Examples' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/text/#perform-case-sensitive-search' + name: Text Search Score Examples + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#perform-case-sensitive-search pipeline: - $match: $text: - $search: 'CAFÉ' + $search: CAFÉ $diacriticSensitive: true - $project: score: - $meta: 'textScore' + $meta: textScore - $sort: score: - $meta: 'textScore' + $meta: textScore - $limit: 5 diff --git a/generator/config/query/type.yaml b/generator/config/query/type.yaml index d8cd7bc86..5cf58e389 100644 --- a/generator/config/query/type.yaml +++ b/generator/config/query/type.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $type -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/type/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/type/ type: - fieldQuery encode: single @@ -15,74 +15,70 @@ arguments: variadic: array tests: - - name: 'Querying by Data Type' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-data-type' + name: Querying by Data Type + link: https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-data-type pipeline: - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 2 - $type: [2] + $type: + - 2 - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'string' - $type: ['string'] + $type: + - string - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 1 - $type: [1] + $type: + - 1 - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'double' - $type: ['double'] + $type: + - double - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'number' - $type: ['number'] + $type: + - number - - name: 'Querying by Multiple Data Type' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-multiple-data-type' + name: Querying by Multiple Data Type + link: https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-multiple-data-type pipeline: - $match: zipCode: - $type: [2, 1] + $type: + - 2 + - 1 - $match: zipCode: - $type: ['string', 'double'] + $type: + - string + - double - - name: 'Querying by MinKey and MaxKey' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-minkey-and-maxkey' + name: Querying by MinKey and MaxKey + link: https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-minkey-and-maxkey pipeline: - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'minKey' - $type: ['minKey'] + $type: + - minKey - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'maxKey' - $type: ['maxKey'] + $type: + - maxKey - - name: 'Querying by Array Type' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-array-type' + name: Querying by Array Type + link: https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-array-type pipeline: - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'array' - $type: ['array'] + $type: + - array diff --git a/generator/config/query/where.yaml b/generator/config/query/where.yaml index 5f5c974ab..0f24bd0ea 100644 --- a/generator/config/query/where.yaml +++ b/generator/config/query/where.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $where -link: 'https://www.mongodb.com/docs/manual/reference/operator/query/where/' +link: https://www.mongodb.com/docs/manual/reference/operator/query/where/ type: - query encode: single @@ -13,8 +13,8 @@ arguments: - javascript tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/where/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/query/where/#example pipeline: - $match: @@ -32,5 +32,6 @@ tests: function(name) { return hex_md5(name) == "9b53e667f30cd329dca1ec9e6a83e994"; } - args: ['$name'] - lang: 'js' + args: + - $name + lang: js diff --git a/generator/config/schema.json b/generator/config/schema.json index 97ef1ce15..c1c51634f 100644 --- a/generator/config/schema.json +++ b/generator/config/schema.json @@ -132,23 +132,57 @@ "range", "sortBy", "geoPoint", - "resolvesToNumber", "numberFieldPath", "number", - "resolvesToDouble", "doubleFieldPath", "double", - "resolvesToString", "stringFieldPath", "string", - "resolvesToObject", "objectFieldPath", "object", - "resolvesToArray", "arrayFieldPath", "array", - "resolvesToBinData", "binDataFieldPath", "binData", - "resolvesToObjectId", "objectIdFieldPath", "objectId", - "resolvesToBool", "boolFieldPath", "bool", - "resolvesToDate", "dateFieldPath", "date", - "resolvesToNull", "nullFieldPath", "null", - "resolvesToRegex", "regexFieldPath", "regex", - "resolvesToJavascript", "javascriptFieldPath", "javascript", - "resolvesToInt", "intFieldPath", "int", - "resolvesToTimestamp", "timestampFieldPath", "timestamp", - "resolvesToLong", "longFieldPath", "long", - "resolvesToDecimal", "decimalFieldPath", "decimal", - "searchPath", "searchScore", "searchOperator" + "resolvesToNumber", + "numberFieldPath", + "number", + "resolvesToDouble", + "doubleFieldPath", + "double", + "resolvesToString", + "stringFieldPath", + "string", + "resolvesToObject", + "objectFieldPath", + "object", + "resolvesToArray", + "arrayFieldPath", + "array", + "resolvesToBinData", + "binDataFieldPath", + "binData", + "resolvesToObjectId", + "objectIdFieldPath", + "objectId", + "resolvesToBool", + "boolFieldPath", + "bool", + "resolvesToDate", + "dateFieldPath", + "date", + "resolvesToNull", + "nullFieldPath", + "null", + "resolvesToRegex", + "regexFieldPath", + "regex", + "resolvesToJavascript", + "javascriptFieldPath", + "javascript", + "resolvesToInt", + "intFieldPath", + "int", + "resolvesToTimestamp", + "timestampFieldPath", + "timestamp", + "resolvesToLong", + "longFieldPath", + "long", + "resolvesToDecimal", + "decimalFieldPath", + "decimal", + "searchPath", + "searchScore", + "searchOperator" ] } }, @@ -183,7 +217,12 @@ }, "default": { "$comment": "The default value for the argument.", - "type": ["array", "boolean", "number", "string"] + "type": [ + "array", + "boolean", + "number", + "string" + ] }, "mergeObject": { "$comment": "Skip the name in object encoding and merge the properties of the value into the operator", @@ -214,8 +253,123 @@ "items": { "type": "object" } + }, + "schema": { + "type": [ + "string", + "object" + ], + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/SimplifiedSchemaField" + } + } } } + }, + "SimplifiedSchemaType": { + "anyOf": [ + { + "$ref": "#/definitions/SimplifiedSchemaBaseType" + }, + { + "$ref": "#/definitions/SimplifiedSchemaArrayType" + }, + { + "$ref": "#/definitions/SimplifiedSchemaDocumentType" + } + ] + }, + "SimplifiedSchemaField": { + "additionalProperties": false, + "properties": { + "types": { + "items": { + "$ref": "#/definitions/SimplifiedSchemaType" + }, + "type": "array" + } + }, + "required": [ + "types" + ], + "type": "object" + }, + "SimplifiedSchemaArrayType": { + "additionalProperties": false, + "properties": { + "bsonType": { + "const": "Array", + "type": "string" + }, + "types": { + "items": { + "type": "object" + }, + "type": "array" + } + }, + "required": [ + "bsonType", + "types" + ], + "type": "object" + }, + "SimplifiedSchemaBaseType": { + "additionalProperties": false, + "properties": { + "bsonType": { + "enum": [ + "Array", + "Binary", + "Boolean", + "Code", + "CodeWScope", + "Date", + "Decimal128", + "Double", + "Int32", + "Int64", + "MaxKey", + "MinKey", + "Null", + "ObjectId", + "BSONRegExp", + "String", + "BSONSymbol", + "Timestamp", + "Undefined", + "Document", + "Number" + ], + "type": "string" + } + }, + "required": [ + "bsonType" + ], + "type": "object" + }, + "SimplifiedSchemaDocumentType": { + "additionalProperties": false, + "properties": { + "bsonType": { + "const": "Document", + "type": "string" + }, + "fields": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + }, + "required": [ + "bsonType", + "fields" + ], + "type": "object" } } } diff --git a/generator/config/search/autocomplete.yaml b/generator/config/search/autocomplete.yaml index a984b9a39..b4ba6abe1 100644 --- a/generator/config/search/autocomplete.yaml +++ b/generator/config/search/autocomplete.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: autocomplete -link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/' +link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/ type: - searchOperator encode: object @@ -22,7 +22,7 @@ arguments: name: tokenOrder optional: true type: - - string # any|sequential + - string - name: fuzzy optional: true @@ -35,30 +35,29 @@ arguments: - searchScore tests: - - name: 'Basic' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#basic-example' + name: Basic + link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#basic-example pipeline: - $search: autocomplete: query: 'off' - path: 'title' + path: title - $limit: 10 - $project: _id: 0 title: 1 - - - name: 'Fuzzy' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#fuzzy-example' + name: Fuzzy + link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#fuzzy-example pipeline: - $search: autocomplete: - query: 'pre' - path: 'title' + query: pre + path: title fuzzy: maxEdits: 1 prefixLength: 1 @@ -69,66 +68,62 @@ tests: $project: _id: 0 title: 1 - - - name: 'Token Order any' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#simple-any-example' + name: Token Order any + link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#simple-any-example pipeline: - $search: autocomplete: - query: 'men with' - path: 'title' - tokenOrder: 'any' + query: men with + path: title + tokenOrder: any - $limit: 4 - $project: _id: 0 title: 1 - - - name: 'Token Order sequential' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#simple-sequential-example' + name: Token Order sequential + link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#simple-sequential-example pipeline: - $search: autocomplete: - query: 'men with' - path: 'title' - tokenOrder: 'sequential' + query: men with + path: title + tokenOrder: sequential - $limit: 4 - $project: _id: 0 title: 1 - - - name: 'Highlighting' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#highlighting-example' + name: Highlighting + link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#highlighting-example pipeline: - $search: autocomplete: - query: 'ger' - path: 'title' + query: ger + path: title highlight: - path: 'title' + path: title - $limit: 5 - $project: score: - $meta: 'searchScore' + $meta: searchScore _id: 0 title: 1 highlights: - $meta: 'searchHighlights' - + $meta: searchHighlights - - name: 'Across Multiple Fields' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#search-across-multiple-fields' + name: Across Multiple Fields + link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#search-across-multiple-fields pipeline: - $search: @@ -136,12 +131,12 @@ tests: should: - autocomplete: - query: 'inter' - path: 'title' + query: inter + path: title - autocomplete: - query: 'inter' - path: 'plot' + query: inter + path: plot minimumShouldMatch: 1 - $limit: 10 diff --git a/generator/config/search/compound.yaml b/generator/config/search/compound.yaml index 7a1d9f419..132d69ed4 100644 --- a/generator/config/search/compound.yaml +++ b/generator/config/search/compound.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: compound -link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/' +link: https://www.mongodb.com/docs/atlas/atlas-search/compound/ type: - searchOperator encode: object @@ -14,25 +14,25 @@ arguments: optional: true type: - searchOperator - - array # of searchOperator + - array - name: mustNot optional: true type: - searchOperator - - array # of searchOperator + - array - name: should optional: true type: - searchOperator - - array # of searchOperator + - array - name: filter optional: true type: - searchOperator - - array # of searchOperator + - array - name: minimumShouldMatch optional: true @@ -45,8 +45,8 @@ arguments: - searchScore tests: - - name: 'must and mustNot' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#must-and-mustnot-example' + name: must and mustNot + link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#must-and-mustnot-example pipeline: - $search: @@ -54,17 +54,16 @@ tests: must: - text: - query: 'varieties' - path: 'description' + query: varieties + path: description mustNot: - text: - query: 'apples' - path: 'description' - + query: apples + path: description - - name: 'must and should' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#must-and-should-example' + name: must and should + link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#must-and-should-example pipeline: - $search: @@ -72,21 +71,20 @@ tests: must: - text: - query: 'varieties' - path: 'description' + query: varieties + path: description should: - text: - query: 'Fuji' - path: 'description' + query: Fuji + path: description - $project: score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'minimumShouldMatch' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#minimumshouldmatch-example' + name: minimumShouldMatch + link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#minimumshouldmatch-example pipeline: - $search: @@ -94,22 +92,21 @@ tests: must: - text: - query: 'varieties' - path: 'description' + query: varieties + path: description should: - text: - query: 'Fuji' - path: 'description' + query: Fuji + path: description - text: - query: 'Golden Delicious' - path: 'description' + query: Golden Delicious + path: description minimumShouldMatch: 1 - - - name: 'Filter' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#filter-examples' + name: Filter + link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#filter-examples pipeline: - $search: @@ -117,22 +114,21 @@ tests: must: - text: - query: 'varieties' - path: 'description' + query: varieties + path: description should: - text: - query: 'banana' - path: 'description' + query: banana + path: description filter: - text: - query: 'granny' - path: 'description' - + query: granny + path: description - - name: 'Nested' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#nested-example' + name: Nested + link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#nested-example pipeline: - $search: @@ -140,17 +136,17 @@ tests: should: - text: - query: 'apple' - path: 'type' + query: apple + path: type - compound: must: - text: - query: 'organic' - path: 'category' + query: organic + path: category - equals: value: true - path: 'in_stock' + path: in_stock minimumShouldMatch: 1 diff --git a/generator/config/search/embeddedDocument.yaml b/generator/config/search/embeddedDocument.yaml index 19c804625..cbeedfd58 100644 --- a/generator/config/search/embeddedDocument.yaml +++ b/generator/config/search/embeddedDocument.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: embeddedDocument -link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/' +link: https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/ type: - searchOperator encode: object @@ -25,28 +25,28 @@ arguments: - searchScore tests: - - name: 'Basic' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#index-definition' + name: Basic + link: https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#index-definition pipeline: - $search: embeddedDocument: - path: 'items' + path: items operator: compound: must: - text: - path: 'items.tags' - query: 'school' + path: items.tags + query: school should: - text: - path: 'items.name' - query: 'backpack' + path: items.name + query: backpack score: embedded: - aggregate: 'mean' + aggregate: mean - $limit: 5 - @@ -55,47 +55,45 @@ tests: items.name: 1 items.tags: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Facet' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#facet-query' + name: Facet + link: https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#facet-query pipeline: - $searchMeta: facet: operator: embeddedDocument: - path: 'items' + path: items operator: compound: must: - text: - path: 'items.tags' - query: 'school' + path: items.tags + query: school should: - text: - path: 'items.name' - query: 'backpack' + path: items.name + query: backpack facets: purchaseMethodFacet: - type: 'string' - path: 'purchaseMethod' - + type: string + path: purchaseMethod - - name: 'Query and Sort' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#query-and-sort' + name: Query and Sort + link: https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#query-and-sort pipeline: - $search: embeddedDocument: - path: 'items' + path: items operator: text: - path: 'items.name' - query: 'laptop' + path: items.name + query: laptop sort: items.tags: 1 - @@ -106,30 +104,29 @@ tests: items.name: 1 items.tags: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Query for Matching Embedded Documents Only' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#query-for-matching-embedded-documents-only' + name: Query for Matching Embedded Documents Only + link: https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#query-for-matching-embedded-documents-only pipeline: - $search: embeddedDocument: - path: 'items' + path: items operator: compound: must: - range: - path: 'items.quantity' + path: items.quantity gt: 2 - exists: - path: 'items.price' + path: items.price - text: - path: 'items.tags' - query: 'school' + path: items.tags + query: school - $limit: 2 - @@ -138,18 +135,18 @@ tests: storeLocation: 1 items: $filter: - input: '$items' + input: $items cond: $and: - $ifNull: - - '$$this.price' + - $$this.price - 'false' - $gt: - - '$$this.quantity' + - $$this.quantity - 2 - $in: - - 'office' - - '$$this.tags' + - office + - $$this.tags diff --git a/generator/config/search/equals.yaml b/generator/config/search/equals.yaml index b3e50c641..28ed5d361 100644 --- a/generator/config/search/equals.yaml +++ b/generator/config/search/equals.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: equals -link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/' +link: https://www.mongodb.com/docs/atlas/atlas-search/equals/ type: - searchOperator encode: object @@ -28,77 +28,75 @@ arguments: - searchScore tests: - - name: 'Boolean' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#boolean-examples' + name: Boolean + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#boolean-examples pipeline: - $search: equals: - path: 'verified_user' + path: verified_user value: true - $project: name: 1 _id: 0 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'ObjectId' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#objectid-example' + name: ObjectId + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#objectid-example pipeline: - $search: equals: - path: 'teammates' - value: !bson_objectId '5a9427648b0beebeb69589a1' - + path: teammates + value: + buffer: !!binary WpQnZIsL7r62lYmh - - name: 'Date' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#date-example' + name: Date + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#date-example pipeline: - $search: equals: - path: 'account_created' - value: !bson_utcdatetime '2022-05-04T05:01:08.000+00:00' - + path: account_created + value: 2022-05-04T05:01:08.000Z - - name: 'Number' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#number-example' + name: Number + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#number-example pipeline: - $search: equals: - path: 'employee_number' + path: employee_number value: 259 - - - name: 'String' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#string-example' + name: String + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#string-example pipeline: - $search: equals: - path: 'name' - value: 'jim hall' - + path: name + value: jim hall - - name: 'UUID' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#uuid-example' + name: UUID + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#uuid-example pipeline: - $search: equals: - path: 'uuid' - value: !bson_uuid 'fac32260-b511-4c69-8485-a2be5b7dda9e' - + path: uuid + value: + sub_type: 4 + buffer: !!binary +sMiYLURTGmEhaK+W33ang== + position: 16 - name: 'Null' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#null-example' + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#null-example pipeline: - $search: equals: - path: 'job_title' - value: ~ + path: job_title + value: null diff --git a/generator/config/search/exists.yaml b/generator/config/search/exists.yaml index 062e8ba59..ad918465a 100644 --- a/generator/config/search/exists.yaml +++ b/generator/config/search/exists.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: exists -link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/' +link: https://www.mongodb.com/docs/atlas/atlas-search/exists/ type: - searchOperator encode: object @@ -18,26 +18,24 @@ arguments: - searchScore tests: - - name: 'Basic' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/#basic-example' + name: Basic + link: https://www.mongodb.com/docs/atlas/atlas-search/exists/#basic-example pipeline: - $search: exists: - path: 'type' - + path: type - - name: 'Embedded' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/#embedded-example' + name: Embedded + link: https://www.mongodb.com/docs/atlas/atlas-search/exists/#embedded-example pipeline: - $search: exists: - path: 'quantities.lemons' - + path: quantities.lemons - - name: 'Compound' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/#compound-example' + name: Compound + link: https://www.mongodb.com/docs/atlas/atlas-search/exists/#compound-example pipeline: - $search: @@ -45,12 +43,12 @@ tests: must: - exists: - path: 'type' + path: type - text: - query: 'apple' - path: 'type' + query: apple + path: type should: text: - query: 'fuji' - path: 'description' + query: fuji + path: description diff --git a/generator/config/search/facet.yaml b/generator/config/search/facet.yaml index 53dc8cba9..a1c17b678 100644 --- a/generator/config/search/facet.yaml +++ b/generator/config/search/facet.yaml @@ -1,8 +1,8 @@ # $schema: ../schema.json name: facet -link: 'https://www.mongodb.com/docs/atlas/atlas-search/facet/' +link: https://www.mongodb.com/docs/atlas/atlas-search/facet/ type: - - searchOperator # should be searchCollector + - searchOperator encode: object description: | The facet collector groups results by values or ranges in the specified @@ -11,7 +11,7 @@ arguments: - name: facets type: - - object # map of facetDefinition + - object - name: operator optional: true @@ -19,21 +19,21 @@ arguments: - searchOperator tests: - - name: 'Facet' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/facet/#examples' + name: Facet + link: https://www.mongodb.com/docs/atlas/atlas-search/facet/#examples pipeline: - $search: facet: operator: near: - path: 'released' - origin: !bson_utcdatetime '1999-07-01T00:00:00.000+00:00' + path: released + origin: 1999-07-01T00:00:00.000Z pivot: 7776000000 facets: genresFacet: - type: 'string' - path: 'genres' + type: string + path: genres - $limit: 2 - @@ -45,12 +45,12 @@ tests: released: 1 meta: - - $replaceWith: '$$SEARCH_META' + $replaceWith: $$SEARCH_META - $limit: 1 - $set: meta: $arrayElemAt: - - '$meta' + - $meta - 0 diff --git a/generator/config/search/geoShape.yaml b/generator/config/search/geoShape.yaml index 4da121e45..2e46c4227 100644 --- a/generator/config/search/geoShape.yaml +++ b/generator/config/search/geoShape.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: geoShape -link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoShape/' +link: https://www.mongodb.com/docs/atlas/atlas-search/geoShape/ type: - searchOperator encode: object @@ -15,7 +15,7 @@ arguments: - name: relation type: - - string # contains | disjoint | intersects | within + - string - name: geometry type: @@ -27,22 +27,30 @@ arguments: - searchScore tests: - - name: 'Disjoint' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#disjoint-example' + name: Disjoint + link: https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#disjoint-example pipeline: - $search: geoShape: - relation: 'disjoint' + relation: disjoint geometry: - type: 'Polygon' + type: Polygon coordinates: - - - [-161.323242, 22.512557] - - [-152.446289, 22.065278] - - [-156.09375, 17.811456] - - [-161.323242, 22.512557] - path: 'address.location' + - + - -161.323242 + - 22.512557 + - + - -152.446289 + - 22.065278 + - + - -156.09375 + - 17.811456 + - + - -161.323242 + - 22.512557 + path: address.location - $limit: 3 - @@ -51,36 +59,59 @@ tests: name: 1 address: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Intersect' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#intersects-example' + name: Intersect + link: https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#intersects-example pipeline: - $search: geoShape: - relation: 'intersects' + relation: intersects geometry: - type: 'MultiPolygon' + type: MultiPolygon coordinates: - - - - [2.16942, 41.40082] - - [2.17963, 41.40087] - - [2.18146, 41.39716] - - [2.15533, 41.40686] - - [2.14596, 41.38475] - - [2.17519, 41.41035] - - [2.16942, 41.40082] + - + - 2.16942 + - 41.40082 + - + - 2.17963 + - 41.40087 + - + - 2.18146 + - 41.39716 + - + - 2.15533 + - 41.40686 + - + - 2.14596 + - 41.38475 + - + - 2.17519 + - 41.41035 + - + - 2.16942 + - 41.40082 - - - - [2.16365, 41.39416] - - [2.16963, 41.39726] - - [2.15395, 41.38005] - - [2.17935, 41.43038] - - [2.16365, 41.39416] - path: 'address.location' + - + - 2.16365 + - 41.39416 + - + - 2.16963 + - 41.39726 + - + - 2.15395 + - 41.38005 + - + - 2.17935 + - 41.43038 + - + - 2.16365 + - 41.39416 + path: address.location - $limit: 3 - @@ -89,29 +120,44 @@ tests: name: 1 address: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Within' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#within-example' + name: Within + link: https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#within-example pipeline: - $search: geoShape: - relation: 'within' + relation: within geometry: - type: 'Polygon' + type: Polygon coordinates: - - - [-74.3994140625, 40.5305017757] - - [-74.7290039063, 40.5805846641] - - [-74.7729492188, 40.9467136651] - - [-74.0698242188, 41.1290213475] - - [-73.65234375, 40.9964840144] - - [-72.6416015625, 40.9467136651] - - [-72.3559570313, 40.7971774152] - - [-74.3994140625, 40.5305017757] - path: 'address.location' + - + - -74.3994140625 + - 40.5305017757 + - + - -74.7290039063 + - 40.5805846641 + - + - -74.7729492188 + - 40.9467136651 + - + - -74.0698242188 + - 41.1290213475 + - + - -73.65234375 + - 40.9964840144 + - + - -72.6416015625 + - 40.9467136651 + - + - -72.3559570313 + - 40.7971774152 + - + - -74.3994140625 + - 40.5305017757 + path: address.location - $limit: 3 - @@ -120,4 +166,4 @@ tests: name: 1 address: 1 score: - $meta: 'searchScore' + $meta: searchScore diff --git a/generator/config/search/geoWithin.yaml b/generator/config/search/geoWithin.yaml index 1739f1997..60ebfc367 100644 --- a/generator/config/search/geoWithin.yaml +++ b/generator/config/search/geoWithin.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: geoWithin -link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/' +link: https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/ type: - searchOperator encode: object @@ -35,20 +35,24 @@ arguments: - searchScore tests: - - name: 'box' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#box-example' + name: box + link: https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#box-example pipeline: - $search: geoWithin: - path: 'address.location' + path: address.location box: bottomLeft: - type: 'Point' - coordinates: [112.467, -55.05] + type: Point + coordinates: + - 112.467 + - -55.05 topRight: - type: 'Point' - coordinates: [168, -9.133] + type: Point + coordinates: + - 168 + - -9.133 - $limit: 3 - @@ -56,20 +60,21 @@ tests: _id: 0 name: 1 address: 1 - - - name: 'circle' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#circle-example' + name: circle + link: https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#circle-example pipeline: - $search: geoWithin: circle: center: - type: 'Point' - coordinates: [-73.54, 45.54] + type: Point + coordinates: + - -73.54 + - 45.54 radius: 1600 - path: 'address.location' + path: address.location - $limit: 3 - @@ -77,23 +82,30 @@ tests: _id: 0 name: 1 address: 1 - - - name: 'geometry' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#geometry-examples' + name: geometry + link: https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#geometry-examples pipeline: - $search: geoWithin: geometry: - type: 'Polygon' + type: Polygon coordinates: - - - [-161.323242, 22.512557] - - [-152.446289, 22.065278] - - [-156.09375, 17.811456] - - [-161.323242, 22.512557] - path: 'address.location' + - + - -161.323242 + - 22.512557 + - + - -152.446289 + - 22.065278 + - + - -156.09375 + - 17.811456 + - + - -161.323242 + - 22.512557 + path: address.location - $limit: 3 - diff --git a/generator/config/search/in.yaml b/generator/config/search/in.yaml index cc1aa6c33..e7a48c90f 100644 --- a/generator/config/search/in.yaml +++ b/generator/config/search/in.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: in -link: 'https://www.mongodb.com/docs/atlas/atlas-search/in/' +link: https://www.mongodb.com/docs/atlas/atlas-search/in/ type: - searchOperator encode: object @@ -15,7 +15,7 @@ arguments: name: value type: - any - - array # of any + - array - name: score optional: true @@ -23,31 +23,30 @@ arguments: - searchScore tests: - - name: 'Single Value Field Match' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/in/#examples' + name: Single Value Field Match + link: https://www.mongodb.com/docs/atlas/atlas-search/in/#examples pipeline: - $search: in: - path: 'birthdate' + path: birthdate value: - - !bson_utcdatetime '1977-03-02T02:20:31.000+00:00' - - !bson_utcdatetime '1977-03-01T00:00:00.000+00:00' - - !bson_utcdatetime '1977-05-06T21:57:35.000+00:00' + - 1977-03-02T02:20:31.000Z + - 1977-03-01T00:00:00.000Z + - 1977-05-06T21:57:35.000Z - $project: _id: 0 name: 1 birthdate: 1 - - - name: 'Array Value Field Match' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/in/#examples' + name: Array Value Field Match + link: https://www.mongodb.com/docs/atlas/atlas-search/in/#examples pipeline: - $search: in: - path: 'accounts' + path: accounts value: - 371138 - 371139 @@ -57,10 +56,9 @@ tests: _id: 0 name: 1 accounts: 1 - - - name: 'Compound Query Match' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/in/#examples' + name: Compound Query Match + link: https://www.mongodb.com/docs/atlas/atlas-search/in/#examples pipeline: - $search: @@ -68,17 +66,19 @@ tests: must: - in: - path: 'name' + path: name value: - - 'james sanchez' - - 'jennifer lawrence' + - james sanchez + - jennifer lawrence should: - in: - path: '_id' + path: _id value: - - !bson_objectId '5ca4bbcea2dd94ee58162a72' - - !bson_objectId '5ca4bbcea2dd94ee58162a91' + - + buffer: !!binary XKS7zqLdlO5YFipy + - + buffer: !!binary XKS7zqLdlO5YFiqR - $limit: 5 - @@ -86,4 +86,4 @@ tests: _id: 1 name: 1 score: - $meta: 'searchScore' + $meta: searchScore diff --git a/generator/config/search/moreLikeThis.yaml b/generator/config/search/moreLikeThis.yaml index 8c4803bdd..4ae452195 100644 --- a/generator/config/search/moreLikeThis.yaml +++ b/generator/config/search/moreLikeThis.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: moreLikeThis -link: 'https://www.mongodb.com/docs/atlas/atlas-search/moreLikeThis/' +link: https://www.mongodb.com/docs/atlas/atlas-search/moreLikeThis/ type: - searchOperator encode: object @@ -13,7 +13,7 @@ arguments: name: like type: - object - - array # of object + - array - name: score optional: true @@ -21,15 +21,15 @@ arguments: - searchScore tests: - - name: 'Single Document with Multiple Fields' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-1--single-document-with-multiple-fields' + name: Single Document with Multiple Fields + link: https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-1--single-document-with-multiple-fields pipeline: - $search: moreLikeThis: like: - title: 'The Godfather' - genres: 'action' + title: The Godfather + genres: action - $limit: 5 - @@ -38,10 +38,9 @@ tests: title: 1 released: 1 genres: 1 - - - name: 'Input Document Excluded in Results' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-2--input-document-excluded-in-results' + name: Input Document Excluded in Results + link: https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-2--input-document-excluded-in-results pipeline: - $search: @@ -50,16 +49,18 @@ tests: - moreLikeThis: like: - _id: !bson_objectId '573a1396f29313caabce4a9a' + _id: + buffer: !!binary VzoTlvKTE8qrzkqa genres: - - 'Crime' - - 'Drama' - title: 'The Godfather' + - Crime + - Drama + title: The Godfather mustNot: - equals: - path: '_id' - value: !bson_objectId '573a1396f29313caabce4a9a' + path: _id + value: + buffer: !!binary VzoTlvKTE8qrzkqa - $limit: 5 - @@ -68,10 +69,9 @@ tests: title: 1 released: 1 genres: 1 - - - name: 'Multiple Analyzers' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-3--multiple-analyzers' + name: Multiple Analyzers + link: https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-3--multiple-analyzers pipeline: - $search: @@ -80,16 +80,18 @@ tests: - moreLikeThis: like: - _id: !bson_objectId '573a1396f29313caabce4a9a' + _id: + buffer: !!binary VzoTlvKTE8qrzkqa genres: - - 'Crime' - - 'Drama' - title: 'The Godfather' + - Crime + - Drama + title: The Godfather mustNot: - equals: - path: '_id' - value: !bson_objectId '573a1394f29313caabcde9ef' + path: _id + value: + buffer: !!binary VzoTlPKTE8qrzenv - $limit: 10 - diff --git a/generator/config/search/near.yaml b/generator/config/search/near.yaml index bd4119cf9..f798d42af 100644 --- a/generator/config/search/near.yaml +++ b/generator/config/search/near.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: near -link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/' +link: https://www.mongodb.com/docs/atlas/atlas-search/near/ type: - searchOperator encode: object @@ -28,14 +28,14 @@ arguments: - searchScore tests: - - name: 'Number' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#number-example' + name: Number + link: https://www.mongodb.com/docs/atlas/atlas-search/near/#number-example pipeline: - $search: - index: 'runtimes' + index: runtimes near: - path: 'runtime' + path: runtime origin: 279 pivot: 2 - @@ -46,18 +46,17 @@ tests: title: 1 runtime: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Date' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#date-example' + name: Date + link: https://www.mongodb.com/docs/atlas/atlas-search/near/#date-example pipeline: - $search: - index: 'releaseddate' + index: releaseddate near: - path: 'released' - origin: !bson_utcdatetime '1915-09-13T00:00:00.000+00:00' + path: released + origin: 1915-09-13T00:00:00.000Z pivot: 7776000000 - $limit: 3 @@ -67,22 +66,21 @@ tests: title: 1 released: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'GeoJSON Point' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#geojson-point-examples' + name: GeoJSON Point + link: https://www.mongodb.com/docs/atlas/atlas-search/near/#geojson-point-examples pipeline: - $search: near: origin: - type: 'Point' + type: Point coordinates: - -8.61308 - 41.1413 pivot: 1000 - path: 'address.location' + path: address.location - $limit: 3 - @@ -91,28 +89,27 @@ tests: name: 1 address: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Compound' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#compound-example' + name: Compound + link: https://www.mongodb.com/docs/atlas/atlas-search/near/#compound-example pipeline: - $search: compound: must: text: - query: 'Apartment' - path: 'property_type' + query: Apartment + path: property_type should: near: origin: - type: 'Point' + type: Point coordinates: - 114.15027 - 22.28158 pivot: 1000 - path: 'address.location' + path: address.location - $limit: 3 - @@ -121,4 +118,4 @@ tests: property_type: 1 address: 1 score: - $meta: 'searchScore' + $meta: searchScore diff --git a/generator/config/search/phrase.yaml b/generator/config/search/phrase.yaml index 4d9b75c4e..291310fb4 100644 --- a/generator/config/search/phrase.yaml +++ b/generator/config/search/phrase.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: phrase -link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/' +link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/ type: - searchOperator encode: object @@ -15,7 +15,7 @@ arguments: name: query type: - string - - array # of string + - array - name: slop optional: true @@ -33,14 +33,14 @@ arguments: - searchScore tests: - - name: 'Single Phrase' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#single-phrase-example' + name: Single Phrase + link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/#single-phrase-example pipeline: - $search: phrase: - path: 'title' - query: 'new york' + path: title + query: new york - $limit: 10 - @@ -48,19 +48,18 @@ tests: _id: 0 title: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Multiple Phrase' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#multiple-phrases-example' + name: Multiple Phrase + link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/#multiple-phrases-example pipeline: - $search: phrase: - path: 'title' + path: title query: - - 'the man' - - 'the moon' + - the man + - the moon - $limit: 10 - @@ -68,36 +67,34 @@ tests: _id: 0 title: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Phrase Slop' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#slop-example' + name: Phrase Slop + link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/#slop-example pipeline: - $search: phrase: - path: 'title' - query: 'men women' + path: title + query: men women slop: 5 - $project: _id: 0 title: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Phrase Synonyms' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#synonyms-example' + name: Phrase Synonyms + link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/#synonyms-example pipeline: - $search: phrase: - path: 'plot' - query: 'automobile race' + path: plot + query: automobile race slop: 5 - synonyms: 'my_synonyms' + synonyms: my_synonyms - $limit: 5 - @@ -106,4 +103,4 @@ tests: plot: 1 title: 1 score: - $meta: 'searchScore' + $meta: searchScore diff --git a/generator/config/search/queryString.yaml b/generator/config/search/queryString.yaml index 8202771c9..bcb63a5eb 100644 --- a/generator/config/search/queryString.yaml +++ b/generator/config/search/queryString.yaml @@ -1,11 +1,10 @@ # $schema: ../schema.json name: queryString -link: 'https://www.mongodb.com/docs/atlas/atlas-search/queryString/' +link: https://www.mongodb.com/docs/atlas/atlas-search/queryString/ type: - searchOperator encode: object -description: | - +description: '' arguments: - name: defaultPath @@ -15,20 +14,16 @@ arguments: name: query type: - string - -# The various example from the doc are variations of the "query" parameter -# this is not pertinent for testing the aggregation builder, unless we create -# a queryString builder. tests: - - name: 'Boolean Operator Queries' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/queryString/#boolean-operator-queries' + name: Boolean Operator Queries + link: https://www.mongodb.com/docs/atlas/atlas-search/queryString/#boolean-operator-queries pipeline: - $search: queryString: - defaultPath: 'title' - query: 'Rocky AND (IV OR 4 OR Four)' + defaultPath: title + query: Rocky AND (IV OR 4 OR Four) - $project: _id: 0 diff --git a/generator/config/search/range.yaml b/generator/config/search/range.yaml index f42c69176..613095754 100644 --- a/generator/config/search/range.yaml +++ b/generator/config/search/range.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: range -link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/' +link: https://www.mongodb.com/docs/atlas/atlas-search/range/ type: - searchOperator encode: object @@ -51,13 +51,13 @@ arguments: - searchScore tests: - - name: 'Number gte lte' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#number-example' + name: Number gte lte + link: https://www.mongodb.com/docs/atlas/atlas-search/range/#number-example pipeline: - $search: range: - path: 'runtime' + path: runtime gte: 2 lte: 3 - @@ -67,15 +67,14 @@ tests: _id: 0 title: 1 runtime: 1 - - - name: 'Number lte' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#number-example' + name: Number lte + link: https://www.mongodb.com/docs/atlas/atlas-search/range/#number-example pipeline: - $search: range: - path: 'runtime' + path: runtime lte: 2 - $limit: 5 @@ -85,18 +84,17 @@ tests: title: 1 runtime: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Date' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#date-example' + name: Date + link: https://www.mongodb.com/docs/atlas/atlas-search/range/#date-example pipeline: - $search: range: - path: 'released' - gt: !bson_utcdatetime '2010-01-01T00:00:00.000Z' - lt: !bson_utcdatetime '2015-01-01T00:00:00.000Z' + path: released + gt: 2010-01-01T00:00:00.000Z + lt: 2015-01-01T00:00:00.000Z - $limit: 5 - @@ -104,33 +102,33 @@ tests: _id: 0 title: 1 released: 1 - - - name: 'ObjectId' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#objectid-example' + name: ObjectId + link: https://www.mongodb.com/docs/atlas/atlas-search/range/#objectid-example pipeline: - $search: range: - path: '_id' - gte: !bson_objectId '573a1396f29313caabce4a9a' - lte: !bson_objectId '573a1396f29313caabce4ae7' + path: _id + gte: + buffer: !!binary VzoTlvKTE8qrzkqa + lte: + buffer: !!binary VzoTlvKTE8qrzkrn - $project: _id: 1 title: 1 released: 1 - - - name: 'String' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#string-example' + name: String + link: https://www.mongodb.com/docs/atlas/atlas-search/range/#string-example pipeline: - $search: range: - path: 'title' - gt: 'city' - lt: 'country' + path: title + gt: city + lt: country - $limit: 5 - diff --git a/generator/config/search/regex.yaml b/generator/config/search/regex.yaml index 869ffabde..2a5d5621d 100644 --- a/generator/config/search/regex.yaml +++ b/generator/config/search/regex.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: regex -link: 'https://www.mongodb.com/docs/atlas/atlas-search/regex/' +link: https://www.mongodb.com/docs/atlas/atlas-search/regex/ type: - searchOperator encode: object @@ -28,13 +28,13 @@ arguments: - searchScore tests: - - name: 'Regex' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/regex/#examples' + name: Regex + link: https://www.mongodb.com/docs/atlas/atlas-search/regex/#examples pipeline: - $search: regex: - path: 'title' + path: title query: '[0-9]{2} (.){4}s' - $project: diff --git a/generator/config/search/text.yaml b/generator/config/search/text.yaml index dbd48cdd0..13029c485 100644 --- a/generator/config/search/text.yaml +++ b/generator/config/search/text.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: text -link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/' +link: https://www.mongodb.com/docs/atlas/atlas-search/text/ type: - searchOperator encode: object @@ -25,7 +25,7 @@ arguments: name: matchCriteria optional: true type: - - string # "any" | "all" + - string - name: synonyms optional: true @@ -38,29 +38,29 @@ arguments: - searchScore tests: - - name: 'Basic' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#basic-example' + name: Basic + link: https://www.mongodb.com/docs/atlas/atlas-search/text/#basic-example pipeline: - $search: text: - path: 'title' - query: 'surfer' + path: title + query: surfer - $project: _id: 0 title: 1 score: - $meta: 'searchScore' + $meta: searchScore - - name: 'Fuzzy Default' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples' + name: Fuzzy Default + link: https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples pipeline: - $search: text: - path: 'title' - query: 'naw yark' + path: title + query: naw yark fuzzy: {} - $limit: 10 @@ -69,17 +69,16 @@ tests: _id: 0 title: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Fuzzy maxExpansions' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples' + name: Fuzzy maxExpansions + link: https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples pipeline: - $search: text: - path: 'title' - query: 'naw yark' + path: title + query: naw yark fuzzy: maxEdits: 1 maxExpansions: 100 @@ -90,17 +89,16 @@ tests: _id: 0 title: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Fuzzy prefixLength' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples' + name: Fuzzy prefixLength + link: https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples pipeline: - $search: text: - path: 'title' - query: 'naw yark' + path: title + query: naw yark fuzzy: maxEdits: 1 prefixLength: 2 @@ -111,19 +109,18 @@ tests: _id: 1 title: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Match any Using equivalent Mapping' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#match-any-using-equivalent-mapping' + name: Match any Using equivalent Mapping + link: https://www.mongodb.com/docs/atlas/atlas-search/text/#match-any-using-equivalent-mapping pipeline: - $search: text: - path: 'plot' - query: 'attire' - synonyms: 'my_synonyms' - matchCriteria: 'any' + path: plot + query: attire + synonyms: my_synonyms + matchCriteria: any - $limit: 5 - @@ -132,19 +129,18 @@ tests: plot: 1 title: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Match any Using explicit Mapping' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#match-any-using-explicit-mapping' + name: Match any Using explicit Mapping + link: https://www.mongodb.com/docs/atlas/atlas-search/text/#match-any-using-explicit-mapping pipeline: - $search: text: - path: 'plot' - query: 'boat race' - synonyms: 'my_synonyms' - matchCriteria: 'any' + path: plot + query: boat race + synonyms: my_synonyms + matchCriteria: any - $limit: 10 - @@ -153,19 +149,18 @@ tests: plot: 1 title: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Match all Using Synonyms' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#match-all-using-synonyms' + name: Match all Using Synonyms + link: https://www.mongodb.com/docs/atlas/atlas-search/text/#match-all-using-synonyms pipeline: - $search: text: - path: 'plot' - query: 'automobile race' - matchCriteria: 'all' - synonyms: 'my_synonyms' + path: plot + query: automobile race + matchCriteria: all + synonyms: my_synonyms - $limit: 20 - @@ -174,21 +169,20 @@ tests: plot: 1 title: 1 score: - $meta: 'searchScore' - + $meta: searchScore - - name: 'Wildcard Path' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/' + name: Wildcard Path + link: https://www.mongodb.com/docs/atlas/atlas-search/text/ pipeline: - $search: text: path: wildcard: '*' - query: 'surfer' + query: surfer - $project: _id: 0 title: 1 score: - $meta: 'searchScore' + $meta: searchScore diff --git a/generator/config/search/wildcard.yaml b/generator/config/search/wildcard.yaml index d17fb4803..fd02aed2c 100644 --- a/generator/config/search/wildcard.yaml +++ b/generator/config/search/wildcard.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: wildcard -link: 'https://www.mongodb.com/docs/atlas/atlas-search/wildcard/' +link: https://www.mongodb.com/docs/atlas/atlas-search/wildcard/ type: - searchOperator encode: object @@ -27,13 +27,13 @@ arguments: - searchScore tests: - - name: 'Wildcard Path' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/wildcard/#index-definition' + name: Wildcard Path + link: https://www.mongodb.com/docs/atlas/atlas-search/wildcard/#index-definition pipeline: - $search: wildcard: - query: 'Wom?n *' + query: Wom?n * path: wildcard: '*' - @@ -42,16 +42,15 @@ tests: $project: _id: 0 title: 1 - - - name: 'Escape Character Example' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/wildcard/#escape-character-example' + name: Escape Character Example + link: https://www.mongodb.com/docs/atlas/atlas-search/wildcard/#escape-character-example pipeline: - $search: wildcard: query: '*\?' - path: 'title' + path: title - $limit: 5 - diff --git a/generator/config/stage/addFields.yaml b/generator/config/stage/addFields.yaml index e98f5de18..b17cb8d4f 100644 --- a/generator/config/stage/addFields.yaml +++ b/generator/config/stage/addFields.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $addFields -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/ type: - stage encode: single @@ -16,42 +16,41 @@ arguments: Specify the name of each field to add and set its value to an aggregation expression or an empty object. tests: - - name: 'Using Two $addFields Stages' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#using-two--addfields-stages' + name: Using Two $addFields Stages + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#using-two--addfields-stages pipeline: - $addFields: totalHomework: - # The example renders a single value, but the builder generates an array for consistency - # $sum: '$homework' - $sum: ['$homework'] + $sum: + - $homework totalQuiz: - # $sum: '$quiz' - $sum: ['$quiz'] + $sum: + - $quiz - $addFields: totalScore: $add: - - '$totalHomework' - - '$totalQuiz' - - '$extraCredit' + - $totalHomework + - $totalQuiz + - $extraCredit - - name: 'Adding Fields to an Embedded Document' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#adding-fields-to-an-embedded-document' + name: Adding Fields to an Embedded Document + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#adding-fields-to-an-embedded-document pipeline: - $addFields: - specs.fuel_type: 'unleaded' + specs.fuel_type: unleaded - - name: 'Overwriting an existing field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#overwriting-an-existing-field' + name: Overwriting an existing field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#overwriting-an-existing-field pipeline: - $addFields: cats: 20 - - name: 'Add Element to an Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#add-element-to-an-array' + name: Add Element to an Array + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#add-element-to-an-array pipeline: - $match: @@ -60,5 +59,6 @@ tests: $addFields: homework: $concatArrays: - - '$homework' - - [7] + - $homework + - + - 7 diff --git a/generator/config/stage/bucket.yaml b/generator/config/stage/bucket.yaml index 0cd65feac..6db170c3a 100644 --- a/generator/config/stage/bucket.yaml +++ b/generator/config/stage/bucket.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bucket -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/ type: - stage encode: object @@ -10,14 +10,14 @@ arguments: - name: groupBy type: - - expression # mainly fieldPath + - expression description: | An expression to group documents by. To specify a field path, prefix the field name with a dollar sign $ and enclose it in quotes. Unless $bucket includes a default specification, each input document must resolve the groupBy field path or expression to a value that falls within one of the ranges specified by the boundaries. - name: boundaries type: - - array # of expression + - array description: | An array of values based on the groupBy expression that specify the boundaries for each bucket. Each adjacent pair of values acts as the inclusive lower boundary and the exclusive upper boundary for the bucket. You must specify at least two boundaries. The specified values must be in ascending order and all of the same type. The exception is if the values are of mixed numeric types, such as: @@ -34,7 +34,7 @@ arguments: - name: output type: - - object # of Accumulator + - object optional: true description: | A document that specifies the fields to include in the output documents in addition to the _id field. To specify the field to include, you must use accumulator expressions. @@ -42,14 +42,19 @@ arguments: If you specify an output document, only the fields specified in the document are returned; i.e. the count field is not returned unless it is explicitly included in the output document. tests: - - name: 'Bucket by Year and Filter by Bucket Results' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/#bucket-by-year-and-filter-by-bucket-results' + name: Bucket by Year and Filter by Bucket Results + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/#bucket-by-year-and-filter-by-bucket-results pipeline: - $bucket: - groupBy: '$year_born' - boundaries: [1840, 1850, 1860, 1870, 1880] - default: 'Other' + groupBy: $year_born + boundaries: + - 1840 + - 1850 + - 1860 + - 1870 + - 1880 + default: Other output: count: $sum: 1 @@ -57,45 +62,52 @@ tests: $push: name: $concat: - - '$first_name' + - $first_name - ' ' - - '$last_name' - year_born: '$year_born' + - $last_name + year_born: $year_born - $match: count: $gt: 3 - - name: 'Use $bucket with $facet to Bucket by Multiple Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/#use--bucket-with--facet-to-bucket-by-multiple-fields' + name: Use $bucket with $facet to Bucket by Multiple Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/#use--bucket-with--facet-to-bucket-by-multiple-fields pipeline: - $facet: price: - $bucket: - groupBy: '$price' - boundaries: [0, 200, 400] - default: 'Other' + groupBy: $price + boundaries: + - 0 + - 200 + - 400 + default: Other output: count: $sum: 1 artwork: $push: - title: '$title' - price: '$price' + title: $title + price: $price averagePrice: - $avg: '$price' + $avg: $price year: - $bucket: - groupBy: '$year' - boundaries: [1890, 1910, 1920, 1940] - default: 'Unknown' + groupBy: $year + boundaries: + - 1890 + - 1910 + - 1920 + - 1940 + default: Unknown output: count: $sum: 1 artwork: $push: - title: '$title' - year: '$year' + title: $title + year: $year diff --git a/generator/config/stage/bucketAuto.yaml b/generator/config/stage/bucketAuto.yaml index 73775fde8..153d4eec0 100644 --- a/generator/config/stage/bucketAuto.yaml +++ b/generator/config/stage/bucketAuto.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $bucketAuto -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucketAuto/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucketAuto/ type: - stage encode: object @@ -22,7 +22,7 @@ arguments: - name: output type: - - object # of Accumulator + - object optional: true description: | A document that specifies the fields to include in the output documents in addition to the _id field. To specify the field to include, you must use accumulator expressions. @@ -37,10 +37,10 @@ arguments: Available only if the all groupBy values are numeric and none of them are NaN. tests: - - name: 'Single Facet Aggregation' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucketAuto/#single-facet-aggregation' + name: Single Facet Aggregation + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucketAuto/#single-facet-aggregation pipeline: - $bucketAuto: - groupBy: '$price' + groupBy: $price buckets: 4 diff --git a/generator/config/stage/changeStream.yaml b/generator/config/stage/changeStream.yaml index be413ef5d..40987377a 100644 --- a/generator/config/stage/changeStream.yaml +++ b/generator/config/stage/changeStream.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $changeStream -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/ type: - stage encode: object @@ -59,8 +59,8 @@ arguments: Specifies a time as the logical starting point for the change stream. Cannot be used with resumeAfter or startAfter fields. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/#examples' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/#examples pipeline: - $changeStream: {} diff --git a/generator/config/stage/changeStreamSplitLargeEvent.yaml b/generator/config/stage/changeStreamSplitLargeEvent.yaml index 208129346..7bf870bd3 100644 --- a/generator/config/stage/changeStreamSplitLargeEvent.yaml +++ b/generator/config/stage/changeStreamSplitLargeEvent.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $changeStreamSplitLargeEvent -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStreamSplitLargeEvent/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStreamSplitLargeEvent/ type: - stage encode: object @@ -9,8 +9,8 @@ description: | You can only use $changeStreamSplitLargeEvent in a $changeStream pipeline and it must be the final stage in the pipeline. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStreamSplitLargeEvent/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStreamSplitLargeEvent/#example pipeline: - $changeStreamSplitLargeEvent: {} diff --git a/generator/config/stage/collStats.yaml b/generator/config/stage/collStats.yaml index 26cbbc470..f990e2274 100644 --- a/generator/config/stage/collStats.yaml +++ b/generator/config/stage/collStats.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $collStats -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/ type: - stage encode: object @@ -20,39 +20,39 @@ arguments: - name: count type: - - object # empty object + - object optional: true - name: queryExecStats type: - - object # empty object + - object optional: true tests: - - name: 'latencyStats Document' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#latencystats-document' + name: latencyStats Document + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#latencystats-document pipeline: - $collStats: latencyStats: histograms: true - - name: 'storageStats Document' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#storagestats-document' + name: storageStats Document + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#storagestats-document pipeline: - $collStats: storageStats: {} - - name: 'count Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#count-field' + name: count Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#count-field pipeline: - $collStats: count: {} - - name: 'queryExecStats Document' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#queryexecstats-document' + name: queryExecStats Document + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#queryexecstats-document pipeline: - $collStats: diff --git a/generator/config/stage/count.yaml b/generator/config/stage/count.yaml index a0fa3ba57..05fc7301f 100644 --- a/generator/config/stage/count.yaml +++ b/generator/config/stage/count.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $count -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/ type: - stage encode: single @@ -16,12 +16,26 @@ arguments: Name of the output field which has the count as its value. It must be a non-empty string, must not start with $ and must not contain the . character. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/#examples pipeline: - $match: score: $gt: 80 - - $count: 'passing_scores' + $count: passing_scores + schema: + scores: + _id: + types: + - + bsonType: Number + subject: + types: + - + bsonType: String + score: + types: + - + bsonType: Number diff --git a/generator/config/stage/currentOp.yaml b/generator/config/stage/currentOp.yaml index 024c71318..0cb2cb1f0 100644 --- a/generator/config/stage/currentOp.yaml +++ b/generator/config/stage/currentOp.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $currentOp -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/ type: - stage encode: object @@ -34,8 +34,8 @@ arguments: optional: true tests: - - name: 'Inactive Sessions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/#inactive-sessions' + name: Inactive Sessions + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/#inactive-sessions pipeline: - $currentOp: @@ -47,8 +47,8 @@ tests: transaction: $exists: true - - name: 'Sampled Queries' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/#sampled-queries' + name: Sampled Queries + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/#sampled-queries pipeline: - $currentOp: @@ -56,4 +56,4 @@ tests: localOps: true - $match: - desc: 'query analyzer' + desc: query analyzer diff --git a/generator/config/stage/densify.yaml b/generator/config/stage/densify.yaml index 46ccbd6dd..7c6d58ee7 100644 --- a/generator/config/stage/densify.yaml +++ b/generator/config/stage/densify.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $densify -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ type: - stage encode: object @@ -10,7 +10,7 @@ arguments: - name: field type: - - string # field name + - string description: | The field to densify. The values of the specified field must either be all numeric values or all dates. Documents that do not contain the specified field continue through the pipeline unmodified. @@ -18,7 +18,7 @@ arguments: - name: partitionByFields type: - - array # of string + - array optional: true description: | The field(s) that will be used as the partition keys. @@ -30,27 +30,27 @@ arguments: Specification for range based densification. tests: - - name: 'Densify Time Series Data' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/#densify-time-series-data' + name: Densify Time Series Data + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/#densify-time-series-data pipeline: - $densify: - field: 'timestamp' + field: timestamp range: step: 1 - unit: 'hour' + unit: hour bounds: - - !bson_utcdatetime '2021-05-18T00:00:00.000Z' - - !bson_utcdatetime '2021-05-18T08:00:00.000Z' + - 2021-05-18T00:00:00.000Z + - 2021-05-18T08:00:00.000Z - - name: 'Densifiction with Partitions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/#densifiction-with-partitions' + name: Densifiction with Partitions + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/#densifiction-with-partitions pipeline: - $densify: - field: 'altitude' + field: altitude partitionByFields: - - 'variety' + - variety range: - bounds: 'full' + bounds: full step: 200 diff --git a/generator/config/stage/documents.yaml b/generator/config/stage/documents.yaml index 666468da8..373c3550c 100644 --- a/generator/config/stage/documents.yaml +++ b/generator/config/stage/documents.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $documents -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/ type: - stage encode: single @@ -10,7 +10,7 @@ arguments: - name: documents type: - - resolvesToArray # of object + - resolvesToArray description: | $documents accepts any valid expression that resolves to an array of objects. This includes: - system variables, such as $$NOW or $$SEARCH_META @@ -19,35 +19,38 @@ arguments: Expressions that do not resolve to a current document, like $myField or $$ROOT, will result in an error. tests: - - name: 'Test a Pipeline Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/#test-a-pipeline-stage' + name: Test a Pipeline Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/#test-a-pipeline-stage pipeline: - $documents: - - { x: 10 } - - { x: 2 } - - { x: 5 } + - + x: 10 + - + x: 2 + - + x: 5 - $bucketAuto: - groupBy: '$x' + groupBy: $x buckets: 4 - - name: 'Use a $documents Stage in a $lookup Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/#use-a--documents-stage-in-a--lookup-stage' + name: Use a $documents Stage in a $lookup Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/#use-a--documents-stage-in-a--lookup-stage pipeline: - $match: {} - $lookup: - localField: 'zip' - foreignField: 'zip_id' - as: 'city_state' + localField: zip + foreignField: zip_id + as: city_state pipeline: - $documents: - zip_id: 94301 - name: 'Palo Alto, CA' + name: Palo Alto, CA - zip_id: 10019 - name: 'New York, NY' + name: New York, NY diff --git a/generator/config/stage/facet.yaml b/generator/config/stage/facet.yaml index 013163c2a..695422b7e 100644 --- a/generator/config/stage/facet.yaml +++ b/generator/config/stage/facet.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $facet -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/ type: - stage encode: single @@ -14,38 +14,39 @@ arguments: variadic: object tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/#example pipeline: - $facet: categorizedByTags: - - # The builder uses the verbose form of the $unwind operator - # $unwind: '$tags' $unwind: - path: '$tags' + path: $tags - - $sortByCount: '$tags' + $sortByCount: $tags categorizedByPrice: - $match: price: - # The example uses an int, but the builder requires a bool - # $exists: 1 $exists: true - $bucket: - groupBy: '$price' - boundaries: [0, 150, 200, 300, 400] - default: 'Other' + groupBy: $price + boundaries: + - 0 + - 150 + - 200 + - 300 + - 400 + default: Other output: count: $sum: 1 titles: - $push: '$title' + $push: $title categorizedByYears(Auto): - $bucketAuto: - groupBy: '$year' + groupBy: $year buckets: 4 diff --git a/generator/config/stage/fill.yaml b/generator/config/stage/fill.yaml index 2c98fac5c..04d2c1f8b 100644 --- a/generator/config/stage/fill.yaml +++ b/generator/config/stage/fill.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $fill -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ type: - stage encode: object @@ -10,7 +10,7 @@ arguments: - name: partitionBy type: - - object # of expression + - object - string optional: true description: | @@ -20,7 +20,7 @@ arguments: - name: partitionByFields type: - - array # of string + - array optional: true description: | Specifies an array of fields as the compound key to group the documents. In the $fill stage, each group of documents is known as a partition. @@ -36,14 +36,14 @@ arguments: - name: output type: - - object # of object{value:expression} or object{method:string}> + - object description: | Specifies an object containing each field for which to fill missing values. You can specify multiple fields in the output object. The object name is the name of the field to fill. The object value specifies how the field is filled. tests: - - name: 'Fill Missing Field Values with a Constant Value' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/#fill-missing-field-values-with-a-constant-value' + name: Fill Missing Field Values with a Constant Value + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/#fill-missing-field-values-with-a-constant-value pipeline: - $fill: @@ -55,8 +55,8 @@ tests: sneakersSold: value: 0 - - name: 'Fill Missing Field Values with Linear Interpolation' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/#fill-missing-field-values-with-linear-interpolation' + name: Fill Missing Field Values with Linear Interpolation + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/#fill-missing-field-values-with-linear-interpolation pipeline: - $fill: @@ -64,10 +64,10 @@ tests: time: 1 output: price: - method: 'linear' + method: linear - - name: 'Fill Missing Field Values Based on the Last Observed Value' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/#fill-missing-field-values-based-on-the-last-observed-value' + name: Fill Missing Field Values Based on the Last Observed Value + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/#fill-missing-field-values-based-on-the-last-observed-value pipeline: - $fill: @@ -75,23 +75,23 @@ tests: date: 1 output: score: - method: 'locf' + method: locf - - name: 'Fill Data for Distinct Partitions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/#fill-data-for-distinct-partitions' + name: Fill Data for Distinct Partitions + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/#fill-data-for-distinct-partitions pipeline: - $fill: sortBy: date: 1 partitionBy: - restaurant: '$restaurant' + restaurant: $restaurant output: score: - method: 'locf' + method: locf - - name: 'Indicate if a Field was Populated Using $fill' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/#indicate-if-a-field-was-populated-using--fill' + name: Indicate if a Field was Populated Using $fill + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/#indicate-if-a-field-was-populated-using--fill pipeline: - $set: @@ -99,7 +99,7 @@ tests: $ifNull: - $toBool: - $toString: '$score' + $toString: $score - false - $fill: @@ -107,4 +107,4 @@ tests: date: 1 output: score: - method: 'locf' + method: locf diff --git a/generator/config/stage/geoNear.yaml b/generator/config/stage/geoNear.yaml index 4967a0823..c49a3b874 100644 --- a/generator/config/stage/geoNear.yaml +++ b/generator/config/stage/geoNear.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $geoNear -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/ type: - stage encode: object @@ -78,84 +78,84 @@ arguments: Default: false. tests: - - name: 'Maximum Distance' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#maximum-distance' + name: Maximum Distance + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#maximum-distance pipeline: - $geoNear: near: - type: 'Point' + type: Point coordinates: - -73.99279 - 40.719296 - distanceField: 'dist.calculated' + distanceField: dist.calculated maxDistance: 2 query: - category: 'Parks' - includeLocs: 'dist.location' + category: Parks + includeLocs: dist.location spherical: true - - name: 'Minimum Distance' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#minimum-distance' + name: Minimum Distance + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#minimum-distance pipeline: - $geoNear: near: - type: 'Point' + type: Point coordinates: - -73.99279 - 40.719296 - distanceField: 'dist.calculated' + distanceField: dist.calculated minDistance: 2 query: - category: 'Parks' - includeLocs: 'dist.location' + category: Parks + includeLocs: dist.location spherical: true - - name: 'with the let option' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#-geonear-with-the-let-option' + name: with the let option + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#-geonear-with-the-let-option pipeline: - $geoNear: - near: '$$pt' - distanceField: 'distance' + near: $$pt + distanceField: distance maxDistance: 2 query: - category: 'Parks' - includeLocs: 'dist.location' + category: Parks + includeLocs: dist.location spherical: true - - name: 'with Bound let Option' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#-geonear-with-bound-let-option' + name: with Bound let Option + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#-geonear-with-bound-let-option pipeline: - $lookup: - from: 'places' + from: places let: - pt: '$location' + pt: $location pipeline: - $geoNear: - near: '$$pt' - distanceField: 'distance' - as: 'joinedField' + near: $$pt + distanceField: distance + as: joinedField - $match: - name: 'Sara D. Roosevelt Park' + name: Sara D. Roosevelt Park - - name: 'Specify Which Geospatial Index to Use' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#specify-which-geospatial-index-to-use' + name: Specify Which Geospatial Index to Use + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#specify-which-geospatial-index-to-use pipeline: - $geoNear: near: - type: 'Point' + type: Point coordinates: - -73.98142 - 40.71782 - key: 'location' - distanceField: 'dist.calculated' + key: location + distanceField: dist.calculated query: - category: 'Parks' + category: Parks - $limit: 5 diff --git a/generator/config/stage/graphLookup.yaml b/generator/config/stage/graphLookup.yaml index ae220620b..ed565216e 100644 --- a/generator/config/stage/graphLookup.yaml +++ b/generator/config/stage/graphLookup.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $graphLookup -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/ type: - stage encode: object @@ -62,47 +62,47 @@ arguments: A document specifying additional conditions for the recursive search. The syntax is identical to query filter syntax. tests: - - name: 'Within a Single Collection' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/#within-a-single-collection' + name: Within a Single Collection + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/#within-a-single-collection pipeline: - $graphLookup: - from: 'employees' - startWith: '$reportsTo' - connectFromField: 'reportsTo' - connectToField: 'name' - as: 'reportingHierarchy' + from: employees + startWith: $reportsTo + connectFromField: reportsTo + connectToField: name + as: reportingHierarchy - - name: 'Across Multiple Collections' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/#across-multiple-collections' + name: Across Multiple Collections + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/#across-multiple-collections pipeline: - $graphLookup: - from: 'airports' - startWith: '$nearestAirport' - connectFromField: 'connects' - connectToField: 'airport' + from: airports + startWith: $nearestAirport + connectFromField: connects + connectToField: airport maxDepth: 2 - depthField: 'numConnections' - as: 'destinations' + depthField: numConnections + as: destinations - - name: 'With a Query Filter' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/#with-a-query-filter' + name: With a Query Filter + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/#with-a-query-filter pipeline: - $match: - name: 'Tanya Jordan' + name: Tanya Jordan - $graphLookup: - from: 'people' - startWith: '$friends' - connectFromField: 'friends' - connectToField: 'name' - as: 'golfers' + from: people + startWith: $friends + connectFromField: friends + connectToField: name + as: golfers restrictSearchWithMatch: - hobbies: 'golf' + hobbies: golf - $project: name: 1 friends: 1 - connections who play golf: '$golfers.name' + connections who play golf: $golfers.name diff --git a/generator/config/stage/group.yaml b/generator/config/stage/group.yaml index a4bae60c2..39bacc77e 100644 --- a/generator/config/stage/group.yaml +++ b/generator/config/stage/group.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $group -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/ type: - stage encode: object @@ -24,100 +24,100 @@ arguments: Computed using the accumulator operators. tests: - - name: 'Count the Number of Documents in a Collection' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#count-the-number-of-documents-in-a-collection' + name: Count the Number of Documents in a Collection + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#count-the-number-of-documents-in-a-collection pipeline: - $group: - _id: ~ + _id: null count: $count: {} - - name: 'Retrieve Distinct Values' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#retrieve-distinct-values' + name: Retrieve Distinct Values + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#retrieve-distinct-values pipeline: - $group: - _id: '$item' + _id: $item - - name: 'Group by Item Having' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-by-item-having' + name: Group by Item Having + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-by-item-having pipeline: - $group: - _id: '$item' + _id: $item totalSaleAmount: $sum: $multiply: - - '$price' - - '$quantity' + - $price + - $quantity - $match: totalSaleAmount: $gte: 100 - - name: 'Calculate Count Sum and Average' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#calculate-count--sum--and-average' + name: Calculate Count Sum and Average + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#calculate-count--sum--and-average pipeline: - $match: date: - $gte: !bson_utcdatetime '2014-01-01' - $lt: !bson_utcdatetime '2015-01-01' + $gte: 2014-01-01T00:00:00.000Z + $lt: 2015-01-01T00:00:00.000Z - $group: _id: $dateToString: format: '%Y-%m-%d' - date: '$date' + date: $date totalSaleAmount: $sum: $multiply: - - '$price' - - '$quantity' + - $price + - $quantity averageQuantity: - $avg: '$quantity' + $avg: $quantity count: $sum: 1 - $sort: totalSaleAmount: -1 - - name: 'Group by null' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-by-null' + name: Group by null + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-by-null pipeline: - $group: - _id: ~ + _id: null totalSaleAmount: $sum: $multiply: - - '$price' - - '$quantity' + - $price + - $quantity averageQuantity: - $avg: '$quantity' + $avg: $quantity count: $sum: 1 - - name: 'Pivot Data' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#pivot-data' + name: Pivot Data + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#pivot-data pipeline: - $group: - _id: '$author' + _id: $author books: - $push: '$title' + $push: $title - - name: 'Group Documents by author' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-documents-by-author' + name: Group Documents by author + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-documents-by-author pipeline: - $group: - _id: '$author' + _id: $author books: - $push: '$$ROOT' + $push: $$ROOT - $addFields: totalCopies: - # $sum: '$books.copies' - $sum: ['$books.copies'] + $sum: + - $books.copies diff --git a/generator/config/stage/indexStats.yaml b/generator/config/stage/indexStats.yaml index 178b209d8..a8dab4930 100644 --- a/generator/config/stage/indexStats.yaml +++ b/generator/config/stage/indexStats.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $indexStats -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/ type: - stage encode: object @@ -8,8 +8,8 @@ description: | Returns statistics regarding the use of each index for the collection. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/#example pipeline: - $indexStats: {} diff --git a/generator/config/stage/limit.yaml b/generator/config/stage/limit.yaml index fff391a01..0bf5b649c 100644 --- a/generator/config/stage/limit.yaml +++ b/generator/config/stage/limit.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $limit -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/ type: - stage encode: single @@ -13,8 +13,8 @@ arguments: - int tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/#example pipeline: - $limit: 5 diff --git a/generator/config/stage/listLocalSessions.yaml b/generator/config/stage/listLocalSessions.yaml index 50dccc30e..729f1ad6f 100644 --- a/generator/config/stage/listLocalSessions.yaml +++ b/generator/config/stage/listLocalSessions.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $listLocalSessions -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/ type: - stage encode: object @@ -23,25 +23,25 @@ arguments: Returns all sessions for all users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster. tests: - - name: 'List All Local Sessions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/#list-all-local-sessions' + name: List All Local Sessions + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/#list-all-local-sessions pipeline: - $listLocalSessions: allUsers: true - - name: 'List All Local Sessions for the Specified Users' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/#list-all-local-sessions-for-the-specified-users' + name: List All Local Sessions for the Specified Users + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/#list-all-local-sessions-for-the-specified-users pipeline: - $listLocalSessions: users: - - user: 'myAppReader' - db: 'test' + user: myAppReader + db: test - - name: 'List All Local Sessions for the Current User' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/#list-all-local-sessions-for-the-current-user' + name: List All Local Sessions for the Current User + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/#list-all-local-sessions-for-the-current-user pipeline: - $listLocalSessions: {} diff --git a/generator/config/stage/listSampledQueries.yaml b/generator/config/stage/listSampledQueries.yaml index f767f0d04..6e8c66cac 100644 --- a/generator/config/stage/listSampledQueries.yaml +++ b/generator/config/stage/listSampledQueries.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $listSampledQueries -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/ type: - stage encode: object @@ -14,16 +14,15 @@ arguments: optional: true tests: - - name: 'List Sampled Queries for All Collections' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/#list-sampled-queries-for-all-collections' + name: List Sampled Queries for All Collections + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/#list-sampled-queries-for-all-collections pipeline: - $listSampledQueries: {} - - - name: 'List Sampled Queries for A Specific Collection' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/#list-sampled-queries-for-a-specific-collection' + name: List Sampled Queries for A Specific Collection + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/#list-sampled-queries-for-a-specific-collection pipeline: - $listSampledQueries: - namespace: 'social.post' + namespace: social.post diff --git a/generator/config/stage/listSearchIndexes.yaml b/generator/config/stage/listSearchIndexes.yaml index afc4f6d05..5ffa1e70f 100644 --- a/generator/config/stage/listSearchIndexes.yaml +++ b/generator/config/stage/listSearchIndexes.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $listSearchIndexes -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/ type: - stage encode: object @@ -23,22 +23,22 @@ arguments: The name of the index to return information about. tests: - - name: 'Return All Search Indexes' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/#return-all-search-indexes' + name: Return All Search Indexes + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/#return-all-search-indexes pipeline: - $listSearchIndexes: {} - - name: 'Return a Single Search Index by Name' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/#return-a-single-search-index-by-name' + name: Return a Single Search Index by Name + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/#return-a-single-search-index-by-name pipeline: - $listSearchIndexes: - name: 'synonym-mappings' + name: synonym-mappings - - name: 'Return a Single Search Index by id' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/#return-a-single-search-index-by-id' + name: Return a Single Search Index by id + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/#return-a-single-search-index-by-id pipeline: - $listSearchIndexes: - id: '6524096020da840844a4c4a7' + id: 6524096020da840844a4c4a7 diff --git a/generator/config/stage/listSessions.yaml b/generator/config/stage/listSessions.yaml index efb56de05..185ef98d3 100644 --- a/generator/config/stage/listSessions.yaml +++ b/generator/config/stage/listSessions.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $listSessions -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/ type: - stage encode: object @@ -23,26 +23,25 @@ arguments: Returns all sessions for all users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster. tests: - - name: 'List All Sessions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/#list-all-sessions' + name: List All Sessions + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/#list-all-sessions pipeline: - $listSessions: allUsers: true - - name: 'List All Sessions for the Specified Users' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/#list-all-sessions-for-the-specified-users' + name: List All Sessions for the Specified Users + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/#list-all-sessions-for-the-specified-users pipeline: - $listSessions: users: - - user: 'myAppReader' - db: 'test' + user: myAppReader + db: test - - name: 'List All Sessions for the Current User' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/#list-all-sessions-for-the-current-user' + name: List All Sessions for the Current User + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/#list-all-sessions-for-the-current-user pipeline: - $listSessions: {} - diff --git a/generator/config/stage/lookup.yaml b/generator/config/stage/lookup.yaml index b73770e47..81a0f9bdf 100644 --- a/generator/config/stage/lookup.yaml +++ b/generator/config/stage/lookup.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $lookup -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/ type: - stage encode: object @@ -33,7 +33,7 @@ arguments: - name: let type: - - object # of expression + - object optional: true description: | Specifies variables to use in the pipeline stages. Use the variable expressions to access the fields from the joined collection's documents that are input to the pipeline. @@ -54,57 +54,57 @@ arguments: Specifies the name of the new array field to add to the input documents. The new array field contains the matching documents from the from collection. If the specified name already exists in the input document, the existing field is overwritten. tests: - - name: 'Perform a Single Equality Join with $lookup' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#perform-a-single-equality-join-with--lookup' + name: Perform a Single Equality Join with $lookup + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#perform-a-single-equality-join-with--lookup pipeline: - $lookup: - from: 'inventory' - localField: 'item' - foreignField: 'sku' - as: 'inventory_docs' + from: inventory + localField: item + foreignField: sku + as: inventory_docs - - name: 'Use $lookup with an Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#use--lookup-with-an-array' + name: Use $lookup with an Array + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#use--lookup-with-an-array pipeline: - $lookup: - from: 'members' - localField: 'enrollmentlist' - foreignField: 'name' - as: 'enrollee_info' + from: members + localField: enrollmentlist + foreignField: name + as: enrollee_info - - name: 'Use $lookup with $mergeObjects' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#use--lookup-with--mergeobjects' + name: Use $lookup with $mergeObjects + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#use--lookup-with--mergeobjects pipeline: - $lookup: - from: 'items' - localField: 'item' - foreignField: 'item' - as: 'fromItems' + from: items + localField: item + foreignField: item + as: fromItems - $replaceRoot: newRoot: $mergeObjects: - $arrayElemAt: - - '$fromItems' + - $fromItems - 0 - - '$$ROOT' + - $$ROOT - $project: fromItems: 0 - - name: 'Perform Multiple Joins and a Correlated Subquery with $lookup' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#perform-multiple-joins-and-a-correlated-subquery-with--lookup' + name: Perform Multiple Joins and a Correlated Subquery with $lookup + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#perform-multiple-joins-and-a-correlated-subquery-with--lookup pipeline: - $lookup: - from: 'warehouses' + from: warehouses let: - order_item: '$item' - order_qty: '$ordered' + order_item: $item + order_qty: $ordered pipeline: - $match: @@ -112,24 +112,24 @@ tests: $and: - $eq: - - '$stock_item' - - '$$order_item' + - $stock_item + - $$order_item - $gte: - - '$instock' - - '$$order_qty' + - $instock + - $$order_qty - $project: stock_item: 0 _id: 0 - as: 'stockdata' + as: stockdata - - name: 'Perform an Uncorrelated Subquery with $lookup' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#perform-an-uncorrelated-subquery-with--lookup' + name: Perform an Uncorrelated Subquery with $lookup + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#perform-an-uncorrelated-subquery-with--lookup pipeline: - $lookup: - from: 'holidays' + from: holidays pipeline: - $match: @@ -138,28 +138,28 @@ tests: $project: _id: 0 date: - name: '$name' - date: '$date' + name: $name + date: $date - $replaceRoot: - newRoot: '$date' - as: 'holidays' + newRoot: $date + as: holidays - - name: 'Perform a Concise Correlated Subquery with $lookup' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#perform-a-concise-correlated-subquery-with--lookup' + name: Perform a Concise Correlated Subquery with $lookup + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#perform-a-concise-correlated-subquery-with--lookup pipeline: - $lookup: - from: 'restaurants' - localField: 'restaurant_name' - foreignField: 'name' + from: restaurants + localField: restaurant_name + foreignField: name let: - orders_drink: '$drink' + orders_drink: $drink pipeline: - $match: $expr: $in: - - '$$orders_drink' - - '$beverages' - as: 'matches' + - $$orders_drink + - $beverages + as: matches diff --git a/generator/config/stage/match.yaml b/generator/config/stage/match.yaml index ab0081fd0..95ed110ee 100644 --- a/generator/config/stage/match.yaml +++ b/generator/config/stage/match.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $match -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/ type: - stage encode: single @@ -13,15 +13,15 @@ arguments: - query tests: - - name: 'Equality Match' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/#equality-match' + name: Equality Match + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/#equality-match pipeline: - $match: - author: 'dave' + author: dave - - name: 'Perform a Count' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/#perform-a-count' + name: Perform a Count + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/#perform-a-count pipeline: - $match: @@ -35,6 +35,6 @@ tests: $gte: 1000 - $group: - _id: ~ + _id: null count: $sum: 1 diff --git a/generator/config/stage/merge.yaml b/generator/config/stage/merge.yaml index 766092d82..21d72d7a0 100644 --- a/generator/config/stage/merge.yaml +++ b/generator/config/stage/merge.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $merge -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/ type: - stage encode: object @@ -19,7 +19,7 @@ arguments: name: 'on' type: - string - - array # of string + - array optional: true description: | Field or fields that act as a unique identifier for a document. The identifier determines if a results document matches an existing document in the output collection. @@ -47,27 +47,27 @@ arguments: The behavior of $merge if a result document does not match an existing document in the out collection. tests: - - name: 'On-Demand Materialized View Initial Creation' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#on-demand-materialized-view--initial-creation' + name: On-Demand Materialized View Initial Creation + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#on-demand-materialized-view--initial-creation pipeline: - $group: _id: - fiscal_year: '$fiscal_year' - dept: '$dept' + fiscal_year: $fiscal_year + dept: $dept salaries: - $sum: '$salary' + $sum: $salary - $merge: into: - db: 'reporting' - coll: 'budgets' - on: '_id' - whenMatched: 'replace' - whenNotMatched: 'insert' + db: reporting + coll: budgets + 'on': _id + whenMatched: replace + whenNotMatched: insert - - name: 'On-Demand Materialized View Update Replace Data' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#on-demand-materialized-view--update-replace-data' + name: On-Demand Materialized View Update Replace Data + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#on-demand-materialized-view--update-replace-data pipeline: - $match: @@ -76,21 +76,21 @@ tests: - $group: _id: - fiscal_year: '$fiscal_year' - dept: '$dept' + fiscal_year: $fiscal_year + dept: $dept salaries: - $sum: '$salary' + $sum: $salary - $merge: into: - db: 'reporting' - coll: 'budgets' - on: '_id' - whenMatched: 'replace' - whenNotMatched: 'insert' + db: reporting + coll: budgets + 'on': _id + whenMatched: replace + whenNotMatched: insert - - name: 'Only Insert New Data' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#only-insert-new-data' + name: Only Insert New Data + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#only-insert-new-data pipeline: - $match: @@ -98,83 +98,83 @@ tests: - $group: _id: - fiscal_year: '$fiscal_year' - dept: '$dept' + fiscal_year: $fiscal_year + dept: $dept employees: - $push: '$employee' + $push: $employee - $project: _id: 0 - dept: '$_id.dept' - fiscal_year: '$_id.fiscal_year' + dept: $_id.dept + fiscal_year: $_id.fiscal_year employees: 1 - $merge: into: - db: 'reporting' - coll: 'orgArchive' - on: - - 'dept' - - 'fiscal_year' - whenMatched: 'fail' + db: reporting + coll: orgArchive + 'on': + - dept + - fiscal_year + whenMatched: fail - - name: 'Merge Results from Multiple Collections' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#merge-results-from-multiple-collections' + name: Merge Results from Multiple Collections + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#merge-results-from-multiple-collections pipeline: - $group: - _id: '$quarter' + _id: $quarter purchased: - $sum: '$qty' + $sum: $qty - $merge: - into: 'quarterlyreport' - on: '_id' - whenMatched: 'merge' - whenNotMatched: 'insert' + into: quarterlyreport + 'on': _id + whenMatched: merge + whenNotMatched: insert - - name: 'Use the Pipeline to Customize the Merge' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#use-the-pipeline-to-customize-the-merge' + name: Use the Pipeline to Customize the Merge + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#use-the-pipeline-to-customize-the-merge pipeline: - $match: date: - $gte: !bson_utcdatetime '2019-05-07' - $lt: !bson_utcdatetime '2019-05-08' + $gte: 2019-05-07T00:00:00.000Z + $lt: 2019-05-08T00:00:00.000Z - $project: _id: $dateToString: format: '%Y-%m' - date: '$date' + date: $date thumbsup: 1 thumbsdown: 1 - $merge: - into: 'monthlytotals' - on: '_id' + into: monthlytotals + 'on': _id whenMatched: - $addFields: thumbsup: $add: - - '$thumbsup' - - '$$new.thumbsup' + - $thumbsup + - $$new.thumbsup thumbsdown: $add: - - '$thumbsdown' - - '$$new.thumbsdown' - whenNotMatched: 'insert' + - $thumbsdown + - $$new.thumbsdown + whenNotMatched: insert - - name: 'Use Variables to Customize the Merge' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#use-variables-to-customize-the-merge' + name: Use Variables to Customize the Merge + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#use-variables-to-customize-the-merge pipeline: - $merge: - into: 'cakeSales' + into: cakeSales let: year: '2020' whenMatched: - $addFields: - salesYear: '$$year' + salesYear: $$year diff --git a/generator/config/stage/out.yaml b/generator/config/stage/out.yaml index 0c3597fdf..3264de0f8 100644 --- a/generator/config/stage/out.yaml +++ b/generator/config/stage/out.yaml @@ -1,13 +1,14 @@ # $schema: ../schema.json name: $out -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/ type: - stage encode: single description: | Writes the resulting documents of the aggregation pipeline to a collection. To use the $out stage, it must be the last stage in the pipeline. arguments: - - name: coll + - + name: coll type: - string - outCollection @@ -15,26 +16,26 @@ arguments: Target database name to write documents from $out to. tests: - - name: 'Output to Same Database' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/#output-to-same-database' + name: Output to Same Database + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/#output-to-same-database pipeline: - $group: - _id: '$author' + _id: $author books: - $push: '$title' + $push: $title - - $out: 'authors' + $out: authors - - name: 'Output to a Different Database' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/#output-to-a-different-database' + name: Output to a Different Database + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/#output-to-a-different-database pipeline: - $group: - _id: '$author' + _id: $author books: - $push: '$title' + $push: $title - $out: - db: 'reporting' - coll: 'authors' + db: reporting + coll: authors diff --git a/generator/config/stage/planCacheStats.yaml b/generator/config/stage/planCacheStats.yaml index 995caa74e..ec7099a58 100644 --- a/generator/config/stage/planCacheStats.yaml +++ b/generator/config/stage/planCacheStats.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $planCacheStats -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/ type: - stage encode: object @@ -8,17 +8,17 @@ description: | Returns plan cache information for a collection. tests: - - name: 'Return Information for All Entries in the Query Cache' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/#return-information-for-all-entries-in-the-query-cache' + name: Return Information for All Entries in the Query Cache + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/#return-information-for-all-entries-in-the-query-cache pipeline: - $planCacheStats: {} - - name: 'Find Cache Entry Details for a Query Hash' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/#find-cache-entry-details-for-a-query-hash' + name: Find Cache Entry Details for a Query Hash + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/#find-cache-entry-details-for-a-query-hash pipeline: - $planCacheStats: {} - $match: - planCacheKey: 'B1435201' + planCacheKey: B1435201 diff --git a/generator/config/stage/project.yaml b/generator/config/stage/project.yaml index bde7c420d..3ef209a56 100644 --- a/generator/config/stage/project.yaml +++ b/generator/config/stage/project.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $project -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/ type: - stage encode: single @@ -11,19 +11,19 @@ arguments: name: specification type: - expression - variadic: object # XXX: This should somehow allow explicit typings for { fieldName: 1|0 } + variadic: object tests: - - name: 'Include Specific Fields in Output Documents' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#include-specific-fields-in-output-documents' + name: Include Specific Fields in Output Documents + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#include-specific-fields-in-output-documents pipeline: - $project: title: 1 author: 1 - - name: 'Suppress id Field in the Output Documents' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#suppress-_id-field-in-the-output-documents' + name: Suppress id Field in the Output Documents + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#suppress-_id-field-in-the-output-documents pipeline: - $project: @@ -31,15 +31,15 @@ tests: title: 1 author: 1 - - name: 'Exclude Fields from Output Documents' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#exclude-fields-from-output-documents' + name: Exclude Fields from Output Documents + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#exclude-fields-from-output-documents pipeline: - $project: lastModified: 0 - - name: 'Exclude Fields from Embedded Documents' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#exclude-fields-from-embedded-documents' + name: Exclude Fields from Embedded Documents + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#exclude-fields-from-embedded-documents pipeline: - $project: @@ -51,8 +51,8 @@ tests: first: 0 lastModified: 0 - - name: 'Conditionally Exclude Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#conditionally-exclude-fields' + name: Conditionally Exclude Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#conditionally-exclude-fields pipeline: - $project: @@ -64,12 +64,12 @@ tests: if: $eq: - '' - - '$author.middle' - then: '$$REMOVE' - else: '$author.middle' + - $author.middle + then: $$REMOVE + else: $author.middle - - name: 'Include Specific Fields from Embedded Documents' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#include-specific-fields-from-embedded-documents' + name: Include Specific Fields from Embedded Documents + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#include-specific-fields-from-embedded-documents pipeline: - $project: @@ -79,8 +79,8 @@ tests: stop: title: 1 - - name: 'Include Computed Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#include-computed-fields' + name: Include Computed Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#include-computed-fields pipeline: - $project: @@ -88,37 +88,37 @@ tests: isbn: prefix: $substr: - - '$isbn' + - $isbn - 0 - 3 group: $substr: - - '$isbn' + - $isbn - 3 - 2 publisher: $substr: - - '$isbn' + - $isbn - 5 - 4 title: $substr: - - '$isbn' + - $isbn - 9 - 3 checkDigit: $substr: - - '$isbn' + - $isbn - 12 - 1 - lastName: '$author.last' - copiesSold: '$copies' + lastName: $author.last + copiesSold: $copies - - name: 'Project New Array Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#project-new-array-fields' + name: Project New Array Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#project-new-array-fields pipeline: - $project: myArray: - - '$x' - - '$y' + - $x + - $y diff --git a/generator/config/stage/redact.yaml b/generator/config/stage/redact.yaml index 07698119c..134e2e3b7 100644 --- a/generator/config/stage/redact.yaml +++ b/generator/config/stage/redact.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $redact -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/ type: - stage encode: single @@ -13,8 +13,8 @@ arguments: - expression tests: - - name: 'Evaluate Access at Every Document Level' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#evaluate-access-at-every-document-level' + name: Evaluate Access at Every Document Level + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#evaluate-access-at-every-document-level pipeline: - $match: @@ -27,26 +27,26 @@ tests: - $size: $setIntersection: - - '$tags' + - $tags - - - 'STLW' - - 'G' + - STLW + - G - 0 - then: '$$DESCEND' - else: '$$PRUNE' + then: $$DESCEND + else: $$PRUNE - - name: 'Exclude All Fields at a Given Level' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#exclude-all-fields-at-a-given-level' + name: Exclude All Fields at a Given Level + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#exclude-all-fields-at-a-given-level pipeline: - $match: - status: 'A' + status: A - $redact: $cond: if: $eq: - - '$level' + - $level - 5 - then: '$$PRUNE' - else: '$$DESCEND' + then: $$PRUNE + else: $$DESCEND diff --git a/generator/config/stage/replaceRoot.yaml b/generator/config/stage/replaceRoot.yaml index 4de474e00..d7d31aad6 100644 --- a/generator/config/stage/replaceRoot.yaml +++ b/generator/config/stage/replaceRoot.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $replaceRoot -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/ type: - stage encode: object @@ -13,8 +13,8 @@ arguments: - resolvesToObject tests: - - name: 'with an Embedded Document Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/#-replaceroot-with-an-embedded-document-field' + name: with an Embedded Document Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/#-replaceroot-with-an-embedded-document-field pipeline: - $replaceRoot: @@ -25,38 +25,36 @@ tests: cats: 0 birds: 0 fish: 0 - - '$pets' + - $pets - - name: 'with a Document Nested in an Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/#-replaceroot-with-a-document-nested-in-an-array' + name: with a Document Nested in an Array + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/#-replaceroot-with-a-document-nested-in-an-array pipeline: - - # The builder uses the verbose form of the $unwind operator - # $unwind: '$grades' $unwind: - path: '$grades' + path: $grades - $match: grades.grade: $gte: 90 - $replaceRoot: - newRoot: '$grades' + newRoot: $grades - - name: 'with a newly created document' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/#-replaceroot-with-a-newly-created-document' + name: with a newly created document + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/#-replaceroot-with-a-newly-created-document pipeline: - $replaceRoot: newRoot: full_name: $concat: - - '$first_name' + - $first_name - ' ' - - '$last_name' + - $last_name - - name: 'with a New Document Created from $$ROOT and a Default Document' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/#-replaceroot-with-a-new-document-created-from---root-and-a-default-document' + name: with a New Document Created from $$ROOT and a Default Document + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/#-replaceroot-with-a-new-document-created-from---root-and-a-default-document pipeline: - $replaceRoot: @@ -68,4 +66,4 @@ tests: email: '' cell: '' home: '' - - '$$ROOT' + - $$ROOT diff --git a/generator/config/stage/replaceWith.yaml b/generator/config/stage/replaceWith.yaml index 10c5fa3a2..ddb4d29de 100644 --- a/generator/config/stage/replaceWith.yaml +++ b/generator/config/stage/replaceWith.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $replaceWith -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/ type: - stage encode: single @@ -14,8 +14,8 @@ arguments: - resolvesToObject tests: - - name: 'an Embedded Document Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/#-replacewith-an-embedded-document-field' + name: an Embedded Document Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/#-replacewith-an-embedded-document-field pipeline: - $replaceWith: @@ -25,42 +25,40 @@ tests: cats: 0 birds: 0 fish: 0 - - '$pets' + - $pets - - name: 'a Document Nested in an Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/#-replacewith-a-document-nested-in-an-array' + name: a Document Nested in an Array + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/#-replacewith-a-document-nested-in-an-array pipeline: - - # The builder uses the verbose form of the $unwind operator - # $unwind: '$grades' $unwind: - path: '$grades' + path: $grades - $match: grades.grade: $gte: 90 - - $replaceWith: '$grades' + $replaceWith: $grades - - name: 'a Newly Created Document' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/#-replacewith-a-newly-created-document' + name: a Newly Created Document + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/#-replacewith-a-newly-created-document pipeline: - $match: - status: 'C' + status: C - $replaceWith: - _id: '$_id' - item: '$item' + _id: $_id + item: $item amount: $multiply: - - '$price' - - '$quantity' - status: 'Complete' - asofDate: '$$NOW' + - $price + - $quantity + status: Complete + asofDate: $$NOW - - name: 'a New Document Created from $$ROOT and a Default Document' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/#-replacewith-a-new-document-created-from---root-and-a-default-document' + name: a New Document Created from $$ROOT and a Default Document + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/#-replacewith-a-new-document-created-from---root-and-a-default-document pipeline: - $replaceWith: @@ -71,4 +69,4 @@ tests: email: '' cell: '' home: '' - - '$$ROOT' + - $$ROOT diff --git a/generator/config/stage/sample.yaml b/generator/config/stage/sample.yaml index 757382aaf..ed5f52bcb 100644 --- a/generator/config/stage/sample.yaml +++ b/generator/config/stage/sample.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $sample -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/ type: - stage encode: object @@ -15,8 +15,8 @@ arguments: The number of documents to randomly select. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/#example pipeline: - $sample: diff --git a/generator/config/stage/search.yaml b/generator/config/stage/search.yaml index 44756ce23..22e2a71d3 100644 --- a/generator/config/stage/search.yaml +++ b/generator/config/stage/search.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $search -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/ type: - stage encode: object @@ -27,8 +27,6 @@ arguments: name: highlight optional: true type: - # @todo support "highlight" type object - # https://www.mongodb.com/docs/atlas/atlas-search/highlighting/ - object description: | Specifies the highlighting options for displaying search terms in their original context. @@ -92,14 +90,14 @@ arguments: Document that specifies the tracking option to retrieve analytics information on the search terms. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/query-syntax/#aggregation-variable' + name: Example + link: https://www.mongodb.com/docs/atlas/atlas-search/query-syntax/#aggregation-variable pipeline: - $search: near: - path: 'released' - origin: !bson_utcdatetime '2011-09-01T00:00:00.000+00:00' + path: released + origin: 2011-09-01T00:00:00.000Z pivot: 7776000000 - $project: @@ -113,19 +111,19 @@ tests: docs: [] meta: - - $replaceWith: '$$SEARCH_META' + $replaceWith: $$SEARCH_META - $limit: 1 - - name: 'Date Search and Sort' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/sort/#date-search-and-sort' + name: Date Search and Sort + link: https://www.mongodb.com/docs/atlas/atlas-search/sort/#date-search-and-sort pipeline: - $search: range: - path: 'released' - gt: !bson_utcdatetime '2010-01-01T00:00:00.000Z' - lt: !bson_utcdatetime '2015-01-01T00:00:00.000Z' + path: released + gt: 2010-01-01T00:00:00.000Z + lt: 2015-01-01T00:00:00.000Z sort: released: -1 - @@ -136,13 +134,13 @@ tests: title: 1 released: 1 - - name: 'Number Search and Sort' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/sort/#number-search-and-sort' + name: Number Search and Sort + link: https://www.mongodb.com/docs/atlas/atlas-search/sort/#number-search-and-sort pipeline: - $search: range: - path: 'awards.wins' + path: awards.wins gt: 3 sort: awards.wins: -1 @@ -154,17 +152,17 @@ tests: title: 1 awards.wins: 1 - - name: 'Sort by score' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/sort/#sort-by-score' + name: Sort by score + link: https://www.mongodb.com/docs/atlas/atlas-search/sort/#sort-by-score pipeline: - $search: text: - path: 'title' - query: 'story' + path: title + query: story sort: score: - $meta: 'searchScore' + $meta: searchScore order: 1 - $limit: 5 @@ -173,65 +171,65 @@ tests: _id: 0 title: 1 score: - $meta: 'searchScore' + $meta: searchScore - - name: 'Paginate results after a token' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/paginate-results/#search-after-the-reference-point' + name: Paginate results after a token + link: https://www.mongodb.com/docs/atlas/atlas-search/paginate-results/#search-after-the-reference-point pipeline: - $search: text: - path: 'title' - query: 'war' + path: title + query: war sort: score: - $meta: 'searchScore' + $meta: searchScore released: 1 - searchAfter: 'CMtJGgYQuq+ngwgaCSkAjBYH7AAAAA==' + searchAfter: CMtJGgYQuq+ngwgaCSkAjBYH7AAAAA== - - name: 'Paginate results before a token' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/paginate-results/#search-before-the-reference-point' + name: Paginate results before a token + link: https://www.mongodb.com/docs/atlas/atlas-search/paginate-results/#search-before-the-reference-point pipeline: - $search: text: - path: 'title' - query: 'war' + path: title + query: war sort: score: - $meta: 'searchScore' + $meta: searchScore released: 1 - searchBefore: 'CJ6kARoGELqvp4MIGgkpACDA3U8BAAA=' + searchBefore: CJ6kARoGELqvp4MIGgkpACDA3U8BAAA= - - name: 'Count results' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/counting/#count-results' + name: Count results + link: https://www.mongodb.com/docs/atlas/atlas-search/counting/#count-results pipeline: - $search: near: - path: 'released' - origin: !bson_utcdatetime '2011-09-01T00:00:00.000+00:00' + path: released + origin: 2011-09-01T00:00:00.000Z pivot: 7776000000 count: - type: 'total' + type: total - $project: - meta: '$$SEARCH_META' + meta: $$SEARCH_META title: 1 released: 1 - $limit: 2 - - name: 'Track Search terms' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/tracking/#examples' + name: Track Search terms + link: https://www.mongodb.com/docs/atlas/atlas-search/tracking/#examples pipeline: - $search: text: - query: 'summer' - path: 'title' + query: summer + path: title tracking: - searchTerms: 'summer' + searchTerms: summer - $limit: 5 - @@ -239,14 +237,14 @@ tests: _id: 0 title: 1 - - name: 'Return Stored Source Fields' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/return-stored-source/#examples' + name: Return Stored Source Fields + link: https://www.mongodb.com/docs/atlas/atlas-search/return-stored-source/#examples pipeline: - $search: text: - query: 'baseball' - path: 'title' + query: baseball + path: title returnStoredSource: true - $match: @@ -259,7 +257,7 @@ tests: $gte: 4500 - $lookup: - from: 'movies' - localField: '_id' - foreignField: '_id' - as: 'document' + from: movies + localField: _id + foreignField: _id + as: document diff --git a/generator/config/stage/searchMeta.yaml b/generator/config/stage/searchMeta.yaml index a7d92c272..3fa1c483e 100644 --- a/generator/config/stage/searchMeta.yaml +++ b/generator/config/stage/searchMeta.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $searchMeta -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/searchMeta/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/searchMeta/ type: - stage encode: object @@ -23,7 +23,6 @@ arguments: - string description: | Name of the Atlas Search index to use. If omitted, defaults to default. - - name: count optional: true @@ -33,100 +32,97 @@ arguments: Document that specifies the count options for retrieving a count of the results. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/query-syntax/#example' + name: Example + link: https://www.mongodb.com/docs/atlas/atlas-search/query-syntax/#example pipeline: - $searchMeta: range: - path: 'year' + path: year gte: 1998 lt: 1999 count: - type: 'total' - + type: total - - name: 'Year Facet' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/facet/#example-1' + name: Year Facet + link: https://www.mongodb.com/docs/atlas/atlas-search/facet/#example-1 pipeline: - - $searchMeta: - facet: - operator: - range: - path: 'year' - gte: 1980 - lte: 2000 - facets: - yearFacet: - type: 'number' - path: 'year' - boundaries: - - 1980 - - 1990 - - 2000 - default: 'other' - + - + $searchMeta: + facet: + operator: + range: + path: year + gte: 1980 + lte: 2000 + facets: + yearFacet: + type: number + path: year + boundaries: + - 1980 + - 1990 + - 2000 + default: other - - name: 'Date Facet' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/facet/#example-2' + name: Date Facet + link: https://www.mongodb.com/docs/atlas/atlas-search/facet/#example-2 pipeline: - $searchMeta: facet: operator: range: - path: 'released' - gte: !bson_utcdatetime '2000-01-01T00:00:00.000Z' - lte: !bson_utcdatetime '2015-01-31T00:00:00.000Z' + path: released + gte: 2000-01-01T00:00:00.000Z + lte: 2015-01-31T00:00:00.000Z facets: yearFacet: - type: 'date' - path: 'released' + type: date + path: released boundaries: - - !bson_utcdatetime '2000-01-01' - - !bson_utcdatetime '2005-01-01' - - !bson_utcdatetime '2010-01-01' - - !bson_utcdatetime '2015-01-01' - default: 'other' - + - 2000-01-01T00:00:00.000Z + - 2005-01-01T00:00:00.000Z + - 2010-01-01T00:00:00.000Z + - 2015-01-01T00:00:00.000Z + default: other - - name: 'Metadata Results' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/facet/#examples' + name: Metadata Results + link: https://www.mongodb.com/docs/atlas/atlas-search/facet/#examples pipeline: - $searchMeta: facet: operator: range: - path: 'released' - gte: !bson_utcdatetime '2000-01-01T00:00:00.000Z' - lte: !bson_utcdatetime '2015-01-31T00:00:00.000Z' + path: released + gte: 2000-01-01T00:00:00.000Z + lte: 2015-01-31T00:00:00.000Z facets: directorsFacet: - type: 'string' - path: 'directors' + type: string + path: directors numBuckets: 7 yearFacet: - type: 'number' - path: 'year' + type: number + path: year boundaries: - 2000 - 2005 - 2010 - 2015 - - - name: 'Autocomplete Bucket Results through Facet Queries' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#bucket-results-through-facet-queries' + name: Autocomplete Bucket Results through Facet Queries + link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#bucket-results-through-facet-queries pipeline: - $searchMeta: facet: operator: autocomplete: - path: 'title' - query: 'Gravity' + path: title + query: Gravity facets: titleFacet: - type: 'string' - path: 'title' + type: string + path: title diff --git a/generator/config/stage/set.yaml b/generator/config/stage/set.yaml index a5861aa29..41531fdb1 100644 --- a/generator/config/stage/set.yaml +++ b/generator/config/stage/set.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $set -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/ type: - stage encode: single @@ -15,42 +15,41 @@ arguments: variadic: object tests: - - name: 'Using Two $set Stages' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#using-two--set-stages' + name: Using Two $set Stages + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#using-two--set-stages pipeline: - $set: totalHomework: - # The $sum expression is always build as an array, even if the value is an array field name - # $sum: '$homework' - $sum: ['$homework'] + $sum: + - $homework totalQuiz: - # $sum: '$quiz' - $sum: ['$quiz'] + $sum: + - $quiz - $set: totalScore: $add: - - '$totalHomework' - - '$totalQuiz' - - '$extraCredit' + - $totalHomework + - $totalQuiz + - $extraCredit - - name: 'Adding Fields to an Embedded Document' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#adding-fields-to-an-embedded-document' + name: Adding Fields to an Embedded Document + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#adding-fields-to-an-embedded-document pipeline: - $set: - specs.fuel_type: 'unleaded' + specs.fuel_type: unleaded - - name: 'Overwriting an existing field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#overwriting-an-existing-field' + name: Overwriting an existing field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#overwriting-an-existing-field pipeline: - $set: cats: 20 - - name: 'Add Element to an Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#add-element-to-an-array' + name: Add Element to an Array + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#add-element-to-an-array pipeline: - $match: @@ -59,15 +58,15 @@ tests: $set: homework: $concatArrays: - - '$homework' + - $homework - - 7 - - name: 'Creating a New Field with Existing Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#creating-a-new-field-with-existing-fields' + name: Creating a New Field with Existing Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#creating-a-new-field-with-existing-fields pipeline: - $set: quizAverage: - # $avg: '$quiz' - $avg: ['$quiz'] + $avg: + - $quiz diff --git a/generator/config/stage/setWindowFields.yaml b/generator/config/stage/setWindowFields.yaml index 6f86472d7..74c053361 100644 --- a/generator/config/stage/setWindowFields.yaml +++ b/generator/config/stage/setWindowFields.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $setWindowFields -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/ type: - stage encode: object @@ -30,115 +30,128 @@ arguments: optional: true tests: - - name: 'Use Documents Window to Obtain Cumulative Quantity for Each State' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-documents-window-to-obtain-cumulative-quantity-for-each-state' + name: Use Documents Window to Obtain Cumulative Quantity for Each State + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-documents-window-to-obtain-cumulative-quantity-for-each-state pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: cumulativeQuantityForState: - $sum: '$quantity' + $sum: $quantity window: - documents: ['unbounded', 'current'] + documents: + - unbounded + - current - - name: 'Use Documents Window to Obtain Cumulative Quantity for Each Year' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-documents-window-to-obtain-cumulative-quantity-for-each-year' + name: Use Documents Window to Obtain Cumulative Quantity for Each Year + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-documents-window-to-obtain-cumulative-quantity-for-each-year pipeline: - $setWindowFields: partitionBy: - # $year: '$orderDate' $year: - date: '$orderDate' + date: $orderDate sortBy: orderDate: 1 output: cumulativeQuantityForYear: - $sum: '$quantity' + $sum: $quantity window: - documents: ['unbounded', 'current'] + documents: + - unbounded + - current - - name: 'Use Documents Window to Obtain Moving Average Quantity for Each Year' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-documents-window-to-obtain-moving-average-quantity-for-each-year' + name: Use Documents Window to Obtain Moving Average Quantity for Each Year + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-documents-window-to-obtain-moving-average-quantity-for-each-year pipeline: - $setWindowFields: partitionBy: - # $year: '$orderDate' $year: - date: '$orderDate' + date: $orderDate sortBy: orderDate: 1 output: averageQuantity: - $avg: '$quantity' + $avg: $quantity window: - documents: [-1, 0] + documents: + - -1 + - 0 - - name: 'Use Documents Window to Obtain Cumulative and Maximum Quantity for Each Year' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-documents-window-to-obtain-cumulative-and-maximum-quantity-for-each-year' + name: Use Documents Window to Obtain Cumulative and Maximum Quantity for Each Year + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-documents-window-to-obtain-cumulative-and-maximum-quantity-for-each-year pipeline: - $setWindowFields: partitionBy: - # $year: '$orderDate' $year: - date: '$orderDate' + date: $orderDate sortBy: orderDate: 1 output: cumulativeQuantityForYear: - $sum: '$quantity' + $sum: $quantity window: - documents: ['unbounded', 'current'] + documents: + - unbounded + - current maximumQuantityForYear: - $max: '$quantity' + $max: $quantity window: - documents: ['unbounded', 'unbounded'] + documents: + - unbounded + - unbounded - - name: 'Range Window Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#range-window-example' + name: Range Window Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#range-window-example pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: price: 1 output: quantityFromSimilarOrders: - $sum: '$quantity' + $sum: $quantity window: - range: [-10, 10] + range: + - -10 + - 10 - - name: 'Use a Time Range Window with a Positive Upper Bound' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-a-time-range-window-with-a-positive-upper-bound' + name: Use a Time Range Window with a Positive Upper Bound + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-a-time-range-window-with-a-positive-upper-bound pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: recentOrders: - $push: '$orderDate' + $push: $orderDate window: - range: ['unbounded', 10] - unit: 'month' + range: + - unbounded + - 10 + unit: month - - name: 'Use a Time Range Window with a Negative Upper Bound' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-a-time-range-window-with-a-negative-upper-bound' + name: Use a Time Range Window with a Negative Upper Bound + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#use-a-time-range-window-with-a-negative-upper-bound pipeline: - $setWindowFields: - partitionBy: '$state' + partitionBy: $state sortBy: orderDate: 1 output: recentOrders: - $push: '$orderDate' + $push: $orderDate window: - range: ['unbounded', -10] - unit: 'month' + range: + - unbounded + - -10 + unit: month diff --git a/generator/config/stage/shardedDataDistribution.yaml b/generator/config/stage/shardedDataDistribution.yaml index 2f298ca0f..9a9f70e5d 100644 --- a/generator/config/stage/shardedDataDistribution.yaml +++ b/generator/config/stage/shardedDataDistribution.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $shardedDataDistribution -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/shardedDataDistribution/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/shardedDataDistribution/ type: - stage encode: object @@ -9,8 +9,8 @@ description: | New in MongoDB 6.0.3. tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/shardedDataDistribution/#examples' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/shardedDataDistribution/#examples pipeline: - $shardedDataDistribution: {} diff --git a/generator/config/stage/skip.yaml b/generator/config/stage/skip.yaml index 2128fe226..abdf2163a 100644 --- a/generator/config/stage/skip.yaml +++ b/generator/config/stage/skip.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $skip -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/ type: - stage encode: single @@ -13,8 +13,8 @@ arguments: - int tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/#example pipeline: - $skip: 5 diff --git a/generator/config/stage/sort.yaml b/generator/config/stage/sort.yaml index d35e23b63..89d3e4944 100644 --- a/generator/config/stage/sort.yaml +++ b/generator/config/stage/sort.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $sort -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/ type: - stage encode: single @@ -15,23 +15,23 @@ arguments: variadic: object tests: - - name: 'Ascending Descending Sort' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/#ascending-descending-sort' + name: Ascending Descending Sort + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/#ascending-descending-sort pipeline: - $sort: age: -1 posts: 1 - - name: 'Text Score Metadata Sort' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/#text-score-metadata-sort' + name: Text Score Metadata Sort + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/#text-score-metadata-sort pipeline: - $match: $text: - $search: 'operating' + $search: operating - $sort: score: - $meta: 'textScore' + $meta: textScore posts: -1 diff --git a/generator/config/stage/sortByCount.yaml b/generator/config/stage/sortByCount.yaml index a32d7aff4..0084d9a63 100644 --- a/generator/config/stage/sortByCount.yaml +++ b/generator/config/stage/sortByCount.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $sortByCount -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/ type: - stage encode: single @@ -13,13 +13,11 @@ arguments: - expression tests: - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/#example' + name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/#example pipeline: - - # The builder uses the verbose form of the $unwind operator - # $unwind: '$tags' $unwind: - path: '$tags' + path: $tags - - $sortByCount: '$tags' + $sortByCount: $tags diff --git a/generator/config/stage/unionWith.yaml b/generator/config/stage/unionWith.yaml index eafa44110..e1622a014 100644 --- a/generator/config/stage/unionWith.yaml +++ b/generator/config/stage/unionWith.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $unionWith -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/ type: - stage encode: object @@ -24,29 +24,29 @@ arguments: The pipeline cannot include the $out and $merge stages. Starting in v6.0, the pipeline can contain the Atlas Search $search stage as the first stage inside the pipeline. tests: - - name: 'Report 1 All Sales by Year and Stores and Items' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/#report-1--all-sales-by-year-and-stores-and-items' + name: Report 1 All Sales by Year and Stores and Items + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/#report-1--all-sales-by-year-and-stores-and-items pipeline: - $set: _id: '2017' - $unionWith: - coll: 'sales_2018' + coll: sales_2018 pipeline: - $set: _id: '2018' - $unionWith: - coll: 'sales_2019' + coll: sales_2019 pipeline: - $set: _id: '2019' - $unionWith: - coll: 'sales_2020' + coll: sales_2020 pipeline: - $set: @@ -57,27 +57,23 @@ tests: store: 1 item: 1 - - name: 'Report 2 Aggregated Sales by Items' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/#report-2--aggregated-sales-by-items' + name: Report 2 Aggregated Sales by Items + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/#report-2--aggregated-sales-by-items pipeline: - - # Example uses the short form, the builder always generates the verbose form - # $unionWith: 'sales_2018' $unionWith: - coll: 'sales_2018' + coll: sales_2018 - - # $unionWith: 'sales_2019' $unionWith: - coll: 'sales_2019' + coll: sales_2019 - - # $unionWith: 'sales_2020' $unionWith: - coll: 'sales_2020' + coll: sales_2020 - $group: - _id: '$item' + _id: $item total: - $sum: '$quantity' + $sum: $quantity - $sort: total: -1 diff --git a/generator/config/stage/unset.yaml b/generator/config/stage/unset.yaml index cef9cdd6d..a3a0a6bda 100644 --- a/generator/config/stage/unset.yaml +++ b/generator/config/stage/unset.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $unset -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/ type: - stage encode: single @@ -15,28 +15,26 @@ arguments: variadic: array tests: - - name: 'Remove a Single Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/#remove-a-single-field' + name: Remove a Single Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/#remove-a-single-field pipeline: - - # The example in the docs uses the short syntax whereas - # the aggregation builder always uses the equivalent array syntax. - # $unset: 'copies' - $unset: ['copies'] + $unset: + - copies - - name: 'Remove Top-Level Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/#remove-top-level-fields' + name: Remove Top-Level Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/#remove-top-level-fields pipeline: - $unset: - - 'isbn' - - 'copies' + - isbn + - copies - - name: 'Remove Embedded Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/#remove-embedded-fields' + name: Remove Embedded Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/#remove-embedded-fields pipeline: - $unset: - - 'isbn' - - 'author.first' - - 'copies.warehouse' + - isbn + - author.first + - copies.warehouse diff --git a/generator/config/stage/unwind.yaml b/generator/config/stage/unwind.yaml index a1f93edbc..def764b9c 100644 --- a/generator/config/stage/unwind.yaml +++ b/generator/config/stage/unwind.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $unwind -link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/' +link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/ type: - stage encode: object @@ -31,65 +31,59 @@ arguments: The default value is false. tests: - - name: 'Unwind Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#unwind-array' + name: Unwind Array + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#unwind-array pipeline: - - # Example uses the short form, the builder always generates the verbose form - # $unwind: '$sizes' $unwind: - path: '$sizes' + path: $sizes - - name: 'preserveNullAndEmptyArrays' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#preservenullandemptyarrays' + name: preserveNullAndEmptyArrays + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#preservenullandemptyarrays pipeline: - $unwind: - path: '$sizes' + path: $sizes preserveNullAndEmptyArrays: true - - name: 'includeArrayIndex' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#includearrayindex' + name: includeArrayIndex + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#includearrayindex pipeline: - $unwind: - path: '$sizes' - includeArrayIndex: 'arrayIndex' + path: $sizes + includeArrayIndex: arrayIndex - - name: 'Group by Unwound Values' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#group-by-unwound-values' + name: Group by Unwound Values + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#group-by-unwound-values pipeline: - $unwind: - path: '$sizes' + path: $sizes preserveNullAndEmptyArrays: true - $group: - _id: '$sizes' + _id: $sizes averagePrice: - $avg: '$price' + $avg: $price - $sort: averagePrice: -1 - - name: 'Unwind Embedded Arrays' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#unwind-embedded-arrays' + name: Unwind Embedded Arrays + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#unwind-embedded-arrays pipeline: - - # Example uses the short form, the builder always generates the verbose form - # $unwind: '$items' $unwind: - path: '$items' + path: $items - - # Example uses the short form, the builder always generates the verbose form - # $unwind: '$items.tags' $unwind: - path: '$items.tags' + path: $items.tags - $group: - _id: '$items.tags' + _id: $items.tags totalSalesAmount: $sum: $multiply: - - '$items.price' - - '$items.quantity' + - $items.price + - $items.quantity diff --git a/generator/config/stage/vectorSearch.yaml b/generator/config/stage/vectorSearch.yaml index bcd3c008a..d11bf4777 100644 --- a/generator/config/stage/vectorSearch.yaml +++ b/generator/config/stage/vectorSearch.yaml @@ -1,6 +1,6 @@ # $schema: ../schema.json name: $vectorSearch -link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/' +link: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/ type: - stage encode: object @@ -28,7 +28,7 @@ arguments: - name: queryVector type: - - array # of numbers + - array description: | Array of numbers that represent the query vector. The number type must match the indexed field value type. - @@ -53,17 +53,19 @@ arguments: description: | This field is required if exact is false or omitted. Number of nearest neighbors to use during the search. Value must be less than or equal to (<=) 10000. You can't specify a number less than the number of documents to return (limit). - tests: - - name: 'ANN Basic' - link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#ann-examples' + name: ANN Basic + link: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#ann-examples pipeline: - $vectorSearch: - index: 'vector_index' - path: 'plot_embedding' - queryVector: [-0.0016261312, -0.028070757, -0.011342932] # skip other numbers, not relevant to the test + index: vector_index + path: plot_embedding + queryVector: + - -0.0016261312 + - -0.028070757 + - -0.011342932 numCandidates: 150 limit: 10 - @@ -72,22 +74,24 @@ tests: plot: 1 title: 1 score: - $meta: 'vectorSearchScore' - + $meta: vectorSearchScore - - name: 'ANN Filter' - link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#ann-examples' + name: ANN Filter + link: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#ann-examples pipeline: - $vectorSearch: - index: 'vector_index' - path: 'plot_embedding' + index: vector_index + path: plot_embedding filter: $and: - year: $lt: 1975 - queryVector: [0.02421053, -0.022372592, -0.006231137] # skip other numbers, not relevant to the test + queryVector: + - 0.02421053 + - -0.022372592 + - -0.006231137 numCandidates: 150 limit: 10 - @@ -97,17 +101,19 @@ tests: plot: 1 year: 1 score: - $meta: 'vectorSearchScore' - + $meta: vectorSearchScore - - name: 'ENN' - link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#enn-examples' + name: ENN + link: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#enn-examples pipeline: - $vectorSearch: - index: 'vector_index' - path: 'plot_embedding' - queryVector: [-0.006954097, -0.009932499, -0.001311474] # skip other numbers, not relevant to the test + index: vector_index + path: plot_embedding + queryVector: + - -0.006954097 + - -0.009932499 + - -0.001311474 exact: true limit: 10 - @@ -116,4 +122,4 @@ tests: plot: 1 title: 1 score: - $meta: 'vectorSearchScore' + $meta: vectorSearchScore