From 39224b6fa3bf421cb20060b2c5235762671c3d57 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 18 Feb 2025 13:08:42 +0100 Subject: [PATCH 01/16] 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 02/16] 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 From 7e645098a1cd627e5601ac0395804b926ceb3a33 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Tue, 20 May 2025 13:44:11 +0200 Subject: [PATCH 03/16] Revert "add tests schema" This reverts commit 56a801b2570876050f63058eface5b8cd645bca8. --- 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, 3302 insertions(+), 6092 deletions(-) diff --git a/generator/config/accumulator/accumulator.yaml b/generator/config/accumulator/accumulator.yaml index a95dfe406..9cfdb6b53 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,14 +52,15 @@ 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: @@ -72,8 +73,7 @@ tests: function(state, numCopies) { return { count: state.count + 1, sum: state.sum + numCopies } } - accumulateArgs: - - $copies + accumulateArgs: [ "$copies" ] merge: $code: |- function(state1, state2) { @@ -87,33 +87,16 @@ tests: function(state) { return (state.sum / state.count) } - lang: js - schema: - books: - _id: - types: - - - bsonType: Number - title: - types: - - - bsonType: String - author: - types: - - - bsonType: String - copies: - types: - - - bsonType: Number + lang: 'js' + - - 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: @@ -122,8 +105,8 @@ tests: return { max: city === userProfileCity ? 3 : 1, restaurants: [] } } initArgs: - - $city - - Bettles + - '$city' + - 'Bettles' accumulate: $code: |- function(state, restaurantName) { @@ -132,8 +115,7 @@ tests: } return state; } - accumulateArgs: - - $name + accumulateArgs: ['$name'] merge: $code: |- function(state1, state2) { @@ -147,22 +129,4 @@ tests: function(state) { return state.restaurants } - lang: js - schema: - restaurants: - _id: - types: - - - bsonType: Number - name: - types: - - - bsonType: String - city: - types: - - - bsonType: String - cuisine: - types: - - - bsonType: String + lang: 'js' diff --git a/generator/config/accumulator/addToSet.yaml b/generator/config/accumulator/addToSet.yaml index 170d13af2..9566899eb 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,83 +13,35 @@ 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: - _id: - day: - $dayOfYear: - date: $date - year: - $year: - date: $date - itemsSold: - $addToSet: $item - schema: - sales: + - $group: _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - price: - types: - - - bsonType: Number - quantity: - types: - - - bsonType: Number - date: - types: - - - bsonType: Date + day: + $dayOfYear: + date: '$date' + year: + $year: + date: '$date' + itemsSold: + $addToSet: '$item' - - 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 - 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 + - 'unbounded' + - 'current' diff --git a/generator/config/accumulator/avg.yaml b/generator/config/accumulator/avg.yaml index 8d426a36f..3777bbf98 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,80 +15,31 @@ 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 - schema: - sales: - _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - price: - types: - - - bsonType: Number - quantity: - types: - - - bsonType: Number - date: - types: - - - bsonType: Date + $avg: '$quantity' - - 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 - 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 + - 'unbounded' + - 'current' diff --git a/generator/config/accumulator/bottom.yaml b/generator/config/accumulator/bottom.yaml index 15138b741..1e363d193 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,61 +23,33 @@ 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 aedb55c6e..355d8e09a 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,98 +30,56 @@ 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + n: 3 - - 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + n: 3 - - 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 c525fde0d..d9819056d 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,47 +11,21 @@ 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: @@ -59,31 +33,5 @@ tests: $count: {} window: 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 + - 'unbounded' + - 'current' diff --git a/generator/config/accumulator/covariancePop.yaml b/generator/config/accumulator/covariancePop.yaml index e059003f4..b43a24022 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,48 +18,24 @@ 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 - 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 + - 'unbounded' + - 'current' diff --git a/generator/config/accumulator/covarianceSamp.yaml b/generator/config/accumulator/covarianceSamp.yaml index 089e53e6f..b6cc529af 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,48 +18,24 @@ 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 - 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 + - 'unbounded' + - 'current' diff --git a/generator/config/accumulator/denseRank.yaml b/generator/config/accumulator/denseRank.yaml index dab4b8f08..0c50dd901 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,78 +9,26 @@ 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 b5a06e13b..5745e9380 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,39 +23,25 @@ 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 3fd086191..b810ccd44 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,40 +9,14 @@ 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 2f3ed8041..3009dd115 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,58 +31,30 @@ 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 - schema: - stockPrices: - stock: - types: - - - bsonType: String - date: - types: - - - bsonType: Date - price: - types: - - - bsonType: Number + input: '$price' + N: 2 - - 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 613d412f2..d82f831a0 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,70 +24,22 @@ tests: date: 1 - $group: - _id: $item + _id: '$item' firstSale: - $first: $date - schema: - sales: - _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - price: - types: - - - bsonType: Number - quantity: - types: - - - bsonType: Number - date: - types: - - - bsonType: Date + $first: '$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 - 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 + - 'unbounded' + - 'current' diff --git a/generator/config/accumulator/firstN.yaml b/generator/config/accumulator/firstN.yaml index 9d2f56452..cb7a6e96c 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,122 +24,99 @@ arguments: A positive integral expression that is either a constant or depends on the _id value for $group. tests: - - 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: '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' pipeline: - $match: - gameId: G1 + gameId: 'G1' - $group: - _id: $gameId + _id: '$gameId' firstThreeScores: $firstN: input: - - $playerId - - $score - 'n': 3 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + - '$playerId' + - '$score' + n: 3 - - 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + - '$playerId' + - '$score' + n: 3 - - 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + - '$playerId' + - '$score' + n: 3 - - 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 46e1de4f1..efc803597 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,35 +23,21 @@ 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 - schema: - powerConsumption: - powerMeterID: - types: - - - bsonType: String - timeStamp: - types: - - - bsonType: Date - kilowatts: - types: - - - bsonType: Number + - 'unbounded' + - 'current' + unit: 'hour' diff --git a/generator/config/accumulator/last.yaml b/generator/config/accumulator/last.yaml index 671c4dab7..969c05524 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,49 +24,22 @@ tests: date: 1 - $group: - _id: $item + _id: '$item' lastSalesDate: - $last: $date - schema: '// TODO: No schema found in docs' + $last: '$date' - - 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 - 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 + - 'current' + - 'unbounded' diff --git a/generator/config/accumulator/lastN.yaml b/generator/config/accumulator/lastN.yaml index 2fc75969a..13c9b72bd 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,122 +24,66 @@ 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + - '$playerId' + - '$score' + n: 3 - - 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + - '$playerId' + - '$score' + n: 3 - - 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + - '$playerId' + - '$score' + n: 3 - - 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 f2a644dc7..034e6ab9e 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,20 +24,10 @@ tests: time: 1 output: price: - $linearFill: $price - schema: - stock: - time: - types: - - - bsonType: Date - price: - types: - - - bsonType: Number + $linearFill: '$price' - - 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: @@ -45,16 +35,6 @@ tests: time: 1 output: linearFillPrice: - $linearFill: $price + $linearFill: '$price' locfPrice: - $locf: $price - schema: - stock: - time: - types: - - - bsonType: Date - price: - types: - - - bsonType: Number + $locf: '$price' diff --git a/generator/config/accumulator/locf.yaml b/generator/config/accumulator/locf.yaml index c01d9486e..63979bca4 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,14 +24,4 @@ tests: time: 1 output: price: - $locf: $price - schema: - stock: - time: - types: - - - bsonType: Date - price: - types: - - - bsonType: Number + $locf: '$price' diff --git a/generator/config/accumulator/max.yaml b/generator/config/accumulator/max.yaml index d1dda0f5e..165cefc43 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,80 +15,32 @@ 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 - schema: - sales: - _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - price: - types: - - - bsonType: Number - quantity: - types: - - - bsonType: Number - date: - types: - - - bsonType: Date + $max: '$quantity' - - 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 - 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 + - 'unbounded' + - 'current' diff --git a/generator/config/accumulator/maxN.yaml b/generator/config/accumulator/maxN.yaml index 25ab9cfae..4014782a8 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,94 +22,52 @@ 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + - '$score' + - '$playerId' + n: 3 - - 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + - '$score' + - '$playerId' + n: 3 - - 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 c3b93800a..e743c6982 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,37 +27,19 @@ 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: null + _id: ~ test01_median: $median: - input: $test01 - method: approximate - schema: - testScores: - studentId: - types: - - - bsonType: String - test01: - types: - - - bsonType: Number - test02: - types: - - - bsonType: Number - test03: - types: - - - bsonType: Number + input: '$test01' + method: 'approximate' - - 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: @@ -66,8 +48,8 @@ tests: output: test01_median: $median: - input: $test01 - method: approximate + input: '$test01' + method: 'approximate' window: range: - -3 @@ -77,21 +59,3 @@ 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 57138ef8f..d68728001 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,54 +15,11 @@ 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 - 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 + $mergeObjects: '$quantity' diff --git a/generator/config/accumulator/min.yaml b/generator/config/accumulator/min.yaml index 20e05b08b..226d56ec8 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,75 +15,27 @@ 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 - schema: - sales: - _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - price: - types: - - - bsonType: Number - quantity: - types: - - - bsonType: Number - date: - types: - - - bsonType: Date + $min: '$quantity' - - 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 - 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 + - 'unbounded' + - 'current' diff --git a/generator/config/accumulator/minN.yaml b/generator/config/accumulator/minN.yaml index b51fbcb30..24719a22a 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,94 +22,52 @@ 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + - '$score' + - '$playerId' + n: 3 - - 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + - '$score' + - '$playerId' + n: 3 - - 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 c2c85da18..b3c41b0e4 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 + - resolvesToArray # of resolvesToNumber 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,100 +37,48 @@ 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: null + _id: ~ test01_percentiles: $percentile: - input: $test01 + input: '$test01' p: - 0.95 - method: approximate - schema: - testScores: - studentId: - types: - - - bsonType: String - test01: - types: - - - bsonType: Number - test02: - types: - - - bsonType: Number - test03: - types: - - - bsonType: Number + method: 'approximate' - - 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: null + _id: ~ 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 - schema: - testScores: - studentId: - types: - - - bsonType: String - test01: - types: - - - bsonType: Number - test02: - types: - - - bsonType: Number - test03: - types: - - - bsonType: Number + input: '$test03' + p: [0.9, 0.5, 0.75, 0.95] + method: 'approximate' - - 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: @@ -139,10 +87,10 @@ tests: output: test01_95percentile: $percentile: - input: $test01 + input: '$test01' p: - 0.95 - method: approximate + method: 'approximate' window: range: - -3 @@ -152,21 +100,3 @@ 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 20b4f1aee..3fc367c59 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,76 +26,30 @@ 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 - schema: - sales: - _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - price: - types: - - - bsonType: Number - quantity: - types: - - - bsonType: Number - date: - types: - - - bsonType: Date + item: '$item' + quantity: '$quantity' - - 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 - 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 + documents: ['unbounded', 'current'] diff --git a/generator/config/accumulator/rank.yaml b/generator/config/accumulator/rank.yaml index 0b6bf37c9..8b8fd041b 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,78 +9,26 @@ 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 5d908f385..f4984f056 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,84 +34,32 @@ 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 - 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 + default: 'Not available' - - 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 - 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 + default: 'Not available' diff --git a/generator/config/accumulator/stdDevPop.yaml b/generator/config/accumulator/stdDevPop.yaml index 3cc1fbeff..8916456d4 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,71 +16,25 @@ 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 - schema: - users: - _id: - types: - - - bsonType: Number - name: - types: - - - bsonType: String - quiz: - types: - - - bsonType: Number - score: - types: - - - bsonType: Number + $stdDevPop: '$score' - - 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 - 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 + documents: ['unbounded', 'current'] diff --git a/generator/config/accumulator/stdDevSamp.yaml b/generator/config/accumulator/stdDevSamp.yaml index b85c1cfb5..94ac33d15 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,70 +16,28 @@ 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: null + _id: ~ ageStdDev: - $stdDevSamp: $age - schema: - TestCollection: - _id: - types: - - - bsonType: Number - username: - types: - - - bsonType: String - age: - types: - - - bsonType: Number + $stdDevSamp: '$age' - - 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 - 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 + documents: ['unbounded', 'current'] diff --git a/generator/config/accumulator/sum.yaml b/generator/config/accumulator/sum.yaml index b3065c841..c40417ef4 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,86 +15,42 @@ 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 - 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 + - 'unbounded' + - 'current' diff --git a/generator/config/accumulator/top.yaml b/generator/config/accumulator/top.yaml index 0bb9f69f4..94923cccd 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,61 +24,33 @@ 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 7848b0af7..c5eff6056 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,98 +30,56 @@ 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + n: 3 - - 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 - schema: - gamescores: - playerId: - types: - - - bsonType: String - gameId: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + n: 3 - - 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 1bd154de4..fe29e44e3 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,27 +13,13 @@ 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 - schema: - temperatureChange: - _id: - types: - - - bsonType: Number - startTemp: - types: - - - bsonType: Number - endTemp: - types: - - - bsonType: Number + - '$startTemp' + - '$endTemp' diff --git a/generator/config/expression/acos.yaml b/generator/config/expression/acos.yaml index e0a4e20b6..7deca736d 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,23 +27,5 @@ tests: $radiansToDegrees: $acos: $divide: - - $side_b - - $hypotenuse - schema: - TestCollection: - _id: - types: - - - bsonType: ObjectId - side_a: - types: - - - bsonType: Decimal128 - side_b: - types: - - - bsonType: Decimal128 - hypotenuse: - types: - - - bsonType: Decimal128 + - '$side_b' + - '$hypotenuse' diff --git a/generator/config/expression/acosh.yaml b/generator/config/expression/acosh.yaml index eda4319f4..ce575e317 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,21 +18,11 @@ 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 - schema: - TestCollection: - _id: - types: - - - bsonType: ObjectId - x-coordinate: - types: - - - bsonType: Decimal128 + $acosh: '$x-coordinate' diff --git a/generator/config/expression/add.yaml b/generator/config/expression/add.yaml index d85af3aa0..fa23253d0 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,68 +21,24 @@ 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 - schema: - TestCollection: - _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - price: - types: - - - bsonType: Number - fee: - types: - - - bsonType: Number - date: - types: - - - bsonType: Date + - '$price' + - '$fee' - - 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 8d2b51e7f..7301f8d68 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,41 +13,13 @@ 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 a5c79681f..96057d249 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,27 +29,9 @@ 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 2024138a1..50fe665b6 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,41 +13,13 @@ 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 2255779ef..09fe9dae1 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,34 +17,17 @@ 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 1f4babc68..87026f7a7 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,98 +13,38 @@ 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 - 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 + - '$dimensions' - - 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 - 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 + - '$instock' diff --git a/generator/config/expression/asin.yaml b/generator/config/expression/asin.yaml index 42af7dc69..43e2832a2 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,23 +27,5 @@ tests: $radiansToDegrees: $asin: $divide: - - $side_a - - $hypotenuse - schema: - TestCollection: - _id: - types: - - - bsonType: ObjectId - side_a: - types: - - - bsonType: Decimal128 - side_b: - types: - - - bsonType: Decimal128 - hypotenuse: - types: - - - bsonType: Decimal128 + - '$side_a' + - '$hypotenuse' diff --git a/generator/config/expression/asinh.yaml b/generator/config/expression/asinh.yaml index 15a40020c..6d45c14fa 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,21 +18,11 @@ 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 - schema: - TestCollection: - _id: - types: - - - bsonType: ObjectId - x-coordinate: - types: - - - bsonType: Decimal128 + $asinh: '$x-coordinate' diff --git a/generator/config/expression/atan.yaml b/generator/config/expression/atan.yaml index e8b022c08..a8bb1674f 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,23 +27,5 @@ tests: $radiansToDegrees: $atan: $divide: - - $side_b - - $side_a - schema: - TestCollection: - _id: - types: - - - bsonType: ObjectId - side_a: - types: - - - bsonType: Decimal128 - side_b: - types: - - - bsonType: Decimal128 - hypotenuse: - types: - - - bsonType: Decimal128 + - '$side_b' + - '$side_a' diff --git a/generator/config/expression/atan2.yaml b/generator/config/expression/atan2.yaml index 235f96d64..1abc55e6a 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,31 +22,13 @@ 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 - schema: - TestCollection: - _id: - types: - - - bsonType: ObjectId - side_a: - types: - - - bsonType: Decimal128 - side_b: - types: - - - bsonType: Decimal128 - hypotenuse: - types: - - - bsonType: Decimal128 + - '$side_b' + - '$side_a' diff --git a/generator/config/expression/atanh.yaml b/generator/config/expression/atanh.yaml index 90dedab3c..501fba2bf 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,21 +18,11 @@ 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 - schema: - TestCollection: - _id: - types: - - - bsonType: ObjectId - x-coordinate: - types: - - - bsonType: Decimal128 + $atanh: '$x-coordinate' diff --git a/generator/config/expression/avg.yaml b/generator/config/expression/avg.yaml index 309efd350..3bb771936 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,46 +15,21 @@ 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 - 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 + - '$final' + - '$midterm' diff --git a/generator/config/expression/binarySize.yaml b/generator/config/expression/binarySize.yaml index 0c517da8f..eb0146f8c 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,25 +15,11 @@ 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 - schema: - images: - _id: - types: - - - bsonType: Number - name: - types: - - - bsonType: String - binary: - types: - - - bsonType: Binary + $binarySize: '$binary' diff --git a/generator/config/expression/bitAnd.yaml b/generator/config/expression/bitAnd.yaml index acc06474e..271cc0973 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,51 +17,22 @@ 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 - schema: - switches: - _id: - types: - - - bsonType: Number - a: - types: - - - bsonType: Int32 - b: - types: - - - bsonType: Int32 + - '$a' + - '$b' - - 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' - schema: - switches: - _id: - types: - - - bsonType: Number - a: - types: - - - bsonType: Int32 - b: - types: - - - bsonType: Int32 + - '$a' + - { "$numberLong": "63" } diff --git a/generator/config/expression/bitNot.yaml b/generator/config/expression/bitNot.yaml index b8a24c856..5211fa42a 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,24 +16,10 @@ 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 - schema: - switches: - _id: - types: - - - bsonType: Number - a: - types: - - - bsonType: Int32 - b: - types: - - - bsonType: Int32 + $bitNot: '$a' diff --git a/generator/config/expression/bitOr.yaml b/generator/config/expression/bitOr.yaml index 4ad7eeb7d..084ac224c 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,51 +17,22 @@ 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 - schema: - switches: - _id: - types: - - - bsonType: Number - a: - types: - - - bsonType: Int32 - b: - types: - - - bsonType: Int32 + - '$a' + - '$b' - - 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' - schema: - switches: - _id: - types: - - - bsonType: Number - a: - types: - - - bsonType: Int32 - b: - types: - - - bsonType: Int32 + - '$a' + - { "$numberLong": "63" } diff --git a/generator/config/expression/bitXor.yaml b/generator/config/expression/bitXor.yaml index a7bcd983a..f4acc4df4 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,26 +17,12 @@ 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 - schema: - switches: - _id: - types: - - - bsonType: Number - a: - types: - - - bsonType: Int32 - b: - types: - - - bsonType: Int32 + - '$a' + - '$b' diff --git a/generator/config/expression/bsonSize.yaml b/generator/config/expression/bsonSize.yaml index 885e6a5cf..712188c52 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,170 +14,35 @@ 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 - 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' + $bsonSize: '$$ROOT' - - 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: null + _id: ~ combined_object_size: $sum: - $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' + $bsonSize: '$$ROOT' - - 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 4cdfd0988..ccf463c90 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 96afa94cb..73c31ddb7 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,21 +15,11 @@ 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 - schema: - samples: - _id: - types: - - - bsonType: Number - value: - types: - - - bsonType: Number + $ceil: '$value' diff --git a/generator/config/expression/cmp.yaml b/generator/config/expression/cmp.yaml index 1d8bd6a69..dd24f9839 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,24 +26,6 @@ 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 69cee5a7d..e8b218d82 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,14 +14,13 @@ 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 - schema: '// TODO: No schema found in docs' + - '$description' diff --git a/generator/config/expression/concatArrays.yaml b/generator/config/expression/concatArrays.yaml index cf5777f5e..026541092 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,32 +14,12 @@ 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 - schema: - warehouses: - _id: - types: - - - bsonType: Number - instock: - types: - - - bsonType: Array - types: - - - bsonType: String - ordered: - types: - - - bsonType: Array - types: - - - bsonType: String + - '$instock' + - '$ordered' diff --git a/generator/config/expression/cond.yaml b/generator/config/expression/cond.yaml index e9b62d065..e2fd66ad7 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,21 +31,7 @@ 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 2a5951e60..a76311ed5 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,27 +35,26 @@ 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: - bytes: !!binary AAAAAAAAAAAAAAAAAABAMA== + input: '$price' + to: 'decimal' + onError: 'Error' + onNull: !bson_decimal128 '0' convertedQty: $convert: - input: $qty - to: int + input: '$qty' + to: 'int' onError: $concat: - 'Could not convert ' - - $toString: $qty + $toString: '$qty' - ' to type integer.' onNull: 0 - @@ -67,39 +66,17 @@ 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 - schema: - orders: - _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - qty: - types: - - - bsonType: Number - price: - types: - - - bsonType: Decimal128 - - - bsonType: Number - - - bsonType: String + - '$convertedPrice' + - '$convertedQty' diff --git a/generator/config/expression/cos.yaml b/generator/config/expression/cos.yaml index 82f2b02cc..0b47670cf 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,19 +26,5 @@ tests: $multiply: - $cos: - $degreesToRadians: $angle_a - - $hypotenuse - schema: - TestCollection: - _id: - types: - - - bsonType: ObjectId - angle_a: - types: - - - bsonType: Decimal128 - hypotenuse: - types: - - - bsonType: Decimal128 + $degreesToRadians: '$angle_a' + - '$hypotenuse' diff --git a/generator/config/expression/cosh.yaml b/generator/config/expression/cosh.yaml index a0c797062..419fa8caa 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,21 +17,11 @@ 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 - schema: - trigonometry: - _id: - types: - - - bsonType: ObjectId - angle: - types: - - - bsonType: Decimal128 + $degreesToRadians: '$angle' diff --git a/generator/config/expression/dateAdd.yaml b/generator/config/expression/dateAdd.yaml index b69828d60..c7d85d571 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,42 +35,34 @@ 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 - schema: - shipping: - custId: - types: - - - bsonType: Number - purchaseDate: - types: - - - bsonType: Date + into: 'shipping' - - 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: @@ -79,24 +71,14 @@ tests: purchased: $dateToString: format: '%Y-%m-%d' - date: $purchaseDate + date: '$purchaseDate' delivery: $dateToString: format: '%Y-%m-%d' - date: $deliveryDate - schema: - shipping: - custId: - types: - - - bsonType: Number - purchaseDate: - types: - - - bsonType: Date + date: '$deliveryDate' - - 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: @@ -105,61 +87,47 @@ 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 - schema: - billing: - location: - types: - - - bsonType: String - login: - types: - - - bsonType: Date - logout: - types: - - - bsonType: Date + timezone: '$location' + timezone: '$location' diff --git a/generator/config/expression/dateDiff.yaml b/generator/config/expression/dateDiff.yaml index 3335a32c7..42cb55d15 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,112 +45,70 @@ 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: null + _id: ~ 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 c46add05b..3ed35004e 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,5 +111,4 @@ tests: hour: 23 minute: 46 second: 12 - timezone: America/New_York - schema: '// TODO: No schema found in docs' + timezone: 'America/New_York' diff --git a/generator/config/expression/dateFromString.yaml b/generator/config/expression/dateFromString.yaml index e92a85f5e..713200f5d 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,82 +46,35 @@ 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 - schema: - logmessages: - _id: - types: - - - bsonType: Number - date: - types: - - - bsonType: String - timezone: - types: - - - bsonType: String - message: - types: - - - bsonType: String + dateString: '$date' + timezone: 'America/New_York' - - 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 - schema: - TestCollection: - _id: - types: - - - bsonType: Number - date: - types: - - - bsonType: String - timezone: - types: - - - bsonType: String + dateString: '$date' + timezone: '$timezone' + onError: '$date' - - 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: 1999-12-31T23:00:00.000Z - schema: - TestCollection: - _id: - types: - - - bsonType: Number - date: - types: - - - bsonType: String - - - bsonType: 'Null' - timezone: - types: - - - bsonType: String + dateString: '$date' + timezone: '$timezone' + onNull: !bson_utcdatetime 0 + diff --git a/generator/config/expression/dateSubtract.yaml b/generator/config/expression/dateSubtract.yaml index c2129fceb..e463fe8f8 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,54 +35,44 @@ 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 - schema: - connectionTime: - custId: - types: - - - bsonType: Number - login: - types: - - - bsonType: Date - logout: - types: - - - bsonType: Date + into: 'connectionTime' - - 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: @@ -91,24 +81,10 @@ tests: loggedOut: $dateToString: format: '%Y-%m-%d' - date: $logoutTime - schema: - connectionTime: - custId: - types: - - - bsonType: Number - login: - types: - - - bsonType: Date - logout: - types: - - - bsonType: Date + date: '$logoutTime' - - 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: @@ -117,61 +93,47 @@ 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 - schema: - billing: - location: - types: - - - bsonType: String - login: - types: - - - bsonType: Date - logout: - types: - - - bsonType: Date + timezone: '$location' + timezone: '$location' diff --git a/generator/config/expression/dateToParts.yaml b/generator/config/expression/dateToParts.yaml index f3af102ce..d250e052f 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,41 +31,19 @@ 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 - schema: - sales: - _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - price: - types: - - - bsonType: Number - quantity: - types: - - - bsonType: Number - date: - types: - - - bsonType: Date + date: '$date' + timezone: 'America/New_York' diff --git a/generator/config/expression/dateToString.yaml b/generator/config/expression/dateToString.yaml index 2b5f23c83..29e0ea8c8 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,64 +40,42 @@ 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 39ead9566..aa3dcd6ca 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,74 +56,22 @@ tests: orderDate: 1 truncatedOrderDate: $dateTrunc: - date: $orderDate - unit: week + date: '$orderDate' + unit: 'week' binSize: 2 - 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 + timezone: 'America/Los_Angeles' + startOfWeek: 'Monday' - - 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 - 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 + $sum: '$quantity' diff --git a/generator/config/expression/dayOfMonth.yaml b/generator/config/expression/dayOfMonth.yaml index 6abab37ce..46a4de0b7 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,33 +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/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 - schema: - sales: - _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - price: - types: - - - bsonType: Number - quantity: - types: - - - bsonType: Number - date: - types: - - - bsonType: Date + date: '$date' diff --git a/generator/config/expression/dayOfWeek.yaml b/generator/config/expression/dayOfWeek.yaml index 46e4d084d..27a6a809d 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,33 +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/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 - schema: - sales: - _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - price: - types: - - - bsonType: Number - quantity: - types: - - - bsonType: Number - date: - types: - - - bsonType: Date + date: '$date' diff --git a/generator/config/expression/dayOfYear.yaml b/generator/config/expression/dayOfYear.yaml index 6279e5d50..8caa0374d 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,33 +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/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 - schema: - sales: - _id: - types: - - - bsonType: Number - item: - types: - - - bsonType: String - price: - types: - - - bsonType: Number - quantity: - types: - - - bsonType: Number - date: - types: - - - bsonType: Date + date: '$date' diff --git a/generator/config/expression/degreesToRadians.yaml b/generator/config/expression/degreesToRadians.yaml index 7388990c8..59c18d2e3 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,28 +17,14 @@ 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 - schema: - TestCollection: - angle_a: - types: - - - bsonType: Decimal128 - angle_b: - types: - - - bsonType: Decimal128 - angle_c: - types: - - - bsonType: Decimal128 + $degreesToRadians: '$angle_c' diff --git a/generator/config/expression/divide.yaml b/generator/config/expression/divide.yaml index 4746cfd61..3b69389d8 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,31 +19,13 @@ arguments: - resolvesToNumber tests: - - name: Example - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/#examples + name: 'Example' + link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/#example' 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 c6e89cada..009280ba1 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,24 +26,6 @@ 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 376ce2e4d..d1f6982a1 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,27 +13,13 @@ 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 62580e9b5..0b72f6d75 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,226 +34,61 @@ 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: Use the limit field - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#use-the-limit-field + name: 'Using the limit field' + link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#using-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 Greater than Possible Matches - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#limit-greater-than-possible-matches + name: 'limit as a Numeric Expression' + link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#limit-as-a-numeric-expression' pipeline: - $project: items: $filter: - input: $items + input: '$items' cond: - $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 + $lte: + - '$$item.price' + - 150 + as: 'item' + limit: 2 - - name: Filter Based on String Equality Match - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#filter-based-on-string-equality-match + 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 - as: item + input: '$items' cond: - $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 + $gte: + - '$$item.price' + - 100 + as: 'item' + limit: 5 diff --git a/generator/config/expression/first.yaml b/generator/config/expression/first.yaml index 92752d666..262d340c3 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,10 +13,9 @@ arguments: - resolvesToArray tests: - - name: Use in $addFields Stage + name: 'Use in $addFields Stage' pipeline: - $addFields: firstItem: - $first: $items - schema: '// TODO: No docs reference found' + $first: '$items' diff --git a/generator/config/expression/firstN.yaml b/generator/config/expression/firstN.yaml index 3439ff02e..e914ff88c 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,32 +19,29 @@ 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 fe1c63074..4c5856264 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 adaa97d56..fa4dba8b5 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 bbbf01141..04b5d4ace 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,20 +25,22 @@ 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: @@ -46,12 +48,14 @@ 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: @@ -60,6 +64,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 9767826a4..da3a35bb2 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 + - expression # lack of backreferral is an issue here 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 af205a127..6b456daf6 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 deaa6c003..ebd62c3a0 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,11 +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/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 2fff0b313..9be8e9044 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 5f8a0a120..7cef8c149 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 4e6aa8324..5840ee0fa 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 20c100735..7fe890891 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 226aa7384..88ed55ec6 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 d234804b9..b9a5d5cb5 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,14 +22,15 @@ 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 edabe65ab..3bce99e99 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 5b5ccd155..1956ff5c4 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,13 +24,15 @@ 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 4399db7ec..2958a20c3 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,13 +24,15 @@ 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 d8769bff0..5dcefa7dd 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,11 +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/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 a7ab9ab9f..2bf18dc7b 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 d5fec386f..0c29ad76e 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,17 +22,18 @@ 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: @@ -46,5 +47,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 0b37e6a6f..7d3017282 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 + - object # of expression 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 5e4da0ccc..dfae7bbb3 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 ce1a06287..f7412aeb9 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 513d7f47f..462eb9492 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 c2234a922..77cab075a 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 6122d5a8c..4b7319b97 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 204cf984f..91c7b1d88 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 09cfe396a..992b70616 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 1807a6202..11db40c24 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,47 +28,49 @@ 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 1572e0b0b..b413679c5 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,18 +15,21 @@ 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 6ffcfaeaf..e0d9d243e 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 96fb6410e..2aac26a1f 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 + - array # of number 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 a750af296..928166852 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 6e43676af..9a96f7aaf 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 e5269ae7f..af1d26e75 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,11 +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/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 86e354de5..1212fd4f7 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,18 +15,21 @@ 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 a7e45716d..e7fa8cac1 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 c553f341c..109e87f6b 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,11 +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/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 14a50bfc8..0ac48bd54 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 c7af36659..7bd383be9 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,11 +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/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 fd4cb7db3..5a069cc8c 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 bd778e5e5..da92f1014 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 d0693de82..d4e4c90ea 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 6b271dc06..460977f33 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,28 +14,31 @@ 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 173bb77f7..2bbce1910 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 671e5897b..b19fc1904 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 + - resolvesToArray # of scalar 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 + - array # of number 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 + - resolvesToArray # of resolvesToNumber 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,11 +46,6 @@ 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 14d182244..afab7f875 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,14 +17,15 @@ 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: - - $stdDevPop: - - $scores.score + # Example uses the short form, the builder always generates the verbose form + # $stdDevPop: '$scores.score' + $stdDevPop: ['$scores.score'] - 2 diff --git a/generator/config/expression/radiansToDegrees.yaml b/generator/config/expression/radiansToDegrees.yaml index 1e360a304..be4dd1e1d 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 d7e2dd969..a19f3163e 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,13 +21,15 @@ 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 053144bab..5c78d8898 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 + - resolvesToArray # of int 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 a23ebef88..bf51eabe3 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,46 +32,47 @@ 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: @@ -81,53 +82,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 32436a4b1..d953a4ae6 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,42 +28,39 @@ 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: - pattern: line - options: '' + input: '$description' + regex: !bson_regex 'line' - - 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: - pattern: line - options: i + input: '$description' + regex: !bson_regex ['line', '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: - pattern: line - options: '' - options: i + input: '$description' + regex: !bson_regex 'line' + options: 'i' diff --git a/generator/config/expression/regexFindAll.yaml b/generator/config/expression/regexFindAll.yaml index 7db3a33f2..6aea184d7 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 + - resolvesToArray # of object encode: object description: | Applies a regular expression (regex) to a string and returns information on the all matched substrings. @@ -28,79 +28,72 @@ 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: - pattern: line - options: '' + input: '$description' + regex: !bson_regex 'line' - - 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: - pattern: line - options: i + input: '$description' + regex: !bson_regex ['line', '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: - pattern: line - options: '' - options: i + input: '$description' + regex: !bson_regex 'line' + 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: - pattern: '[a-z0-9_.+-]+@[a-z0-9_.+-]+\.[a-z0-9_.+-]+' - options: i + input: '$comment' + regex: !bson_regex ['[a-z0-9_.+-]+@[a-z0-9_.+-]+\.[a-z0-9_.+-]+', '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: - pattern: ([a-z0-9_.+-]+)@[a-z0-9_.+-]+\.[a-z0-9_.+-]+ - options: i + input: '$comment' + regex: !bson_regex ['([a-z0-9_.+-]+)@[a-z0-9_.+-]+\.[a-z0-9_.+-]+', '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 ce204946c..4ea9f0aab 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,48 +28,45 @@ 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: - pattern: line - options: '' + input: '$description' + regex: !bson_regex 'line' - - 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: - pattern: line - options: i + input: '$description' + regex: !bson_regex ['line', '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: - pattern: line - options: '' - options: i + input: '$description' + regex: !bson_regex 'line' + 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: @@ -77,9 +74,7 @@ tests: $cond: if: $regexMatch: - input: $comment - regex: - pattern: '[a-z0-9_.+-]+@mongodb.com' - options: i - then: Employee - else: External + input: '$comment' + regex: !bson_regex ['[a-z0-9_.+-]+@mongodb.com', 'i'] + then: 'Employee' + else: 'External' diff --git a/generator/config/expression/replaceAll.yaml b/generator/config/expression/replaceAll.yaml index f21f1ffd1..74d479cb7 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 52d444820..0962cc6c5 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 2fb3c4c67..2cbe3f3cd 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 8c437e66f..9bc6961c7 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 9fc7fcf66..a9d1974db 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 5cef3cf3e..83e7fd370 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,11 +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/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 2bedca948..69f448cb7 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 e5486b220..5194c9ae9 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 76d48b800..b53cf6584 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,35 +29,39 @@ 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: @@ -65,12 +69,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: @@ -79,27 +83,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 5f75d23e2..8f03651d5 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,21 +23,22 @@ 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 9cacade87..fe7c9ed02 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,6 +26,7 @@ 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 b92d0193b..2cfca3e16 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 60a15c425..fe02b4f28 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 ea391e6b1..a5b446add 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 c526e09e8..ce4fe775e 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,8 +24,10 @@ 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 982857121..22cc287e1 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 19bfb0f53..d558f2233 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,19 +91,18 @@ tests: - 20 - 4 - - a: Free + a: 'Free' - 6 - 21 - 5 - - Gratis + - 'Gratis' - - a: null + a: ~ - a: sale: true price: 19 + - !bson_decimal128 '10.23' - - bytes: !!binary AQAAAAAAAAAAAAAAAABAMA== - - - a: On sale + a: 'On sale' sortBy: 1 diff --git a/generator/config/expression/split.yaml b/generator/config/expression/split.yaml index 0cd63fd40..1c6169910 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 + - resolvesToArray # of string 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,30 +21,28 @@ 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: - pattern: '[A-Z]{2}' - options: '' + city_state: !bson_regex '[A-Z]{2}' - $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 be98c997d..52f5bb7c2 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 1e5479666..46641ebe8 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,11 +16,12 @@ 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: - $stdDevPop: - - $scores.score + # Example uses the short form, the builder always generates the verbose form + # $stdDevPop: '$scores.score' + $stdDevPop: ['$scores.score'] diff --git a/generator/config/expression/stdDevSamp.yaml b/generator/config/expression/stdDevSamp.yaml index 008110c7d..84b35f52a 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 9f1fca514..301150d19 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 3c1ef1c9e..b852c80ec 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 d6254f939..6775c44b1 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 d242baab5..6bcf6143f 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 04ec2615e..fed7677c8 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 c585067ef..843b2ca1a 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 0275bbcd1..b6db65ac9 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 f0857c10a..25b323ab1 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,18 +16,21 @@ 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 2dd5ec120..d668e3d94 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 + - array # of CaseOperator 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 c23e1dd85..17b11ee63 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 061b8e29f..364589452 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 23afcbf51..7f771ec8d 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 e299e2a9c..d9434a6bd 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 f9956919d..2f3588323 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 67098ab76..f34c36e9a 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 ee1188739..f5811f56d 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 802ee7920..2b0239955 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 bf9664339..3168ad9ff 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 b23f82e0e..0d6176672 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 72261b31f..803f7cafa 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 da5867bab..0fd068562 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 0045912db..c2c71e1bc 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 c908e5c3a..d63423910 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 b83348491..f930cf027 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 2b3b0cc1c..9fded2143 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 768612dd6..20a84904b 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 d905dce94..c1f63db79 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 a1a1218fb..a4365a646 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,36 +22,38 @@ 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 822ae09da..6086f57ee 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,11 +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/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 90063da82..3326e3495 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,11 +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/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 e256c782d..76402dac5 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 + - resolvesToArray # of array encode: object description: | Merge two arrays together. @@ -10,7 +10,7 @@ arguments: - name: inputs type: - - resolvesToArray + - resolvesToArray # of array 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 1615951a7..868e205e2 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 c55e83625..74ebf506e 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 9047a474b..48e98037d 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,34 +12,27 @@ arguments: type: - int - binData - - array + - array # of int 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: - sub_type: 0 - buffer: !!binary AAAA - position: 0 + - $match: + a: + $bitsAllClear: !bson_binary 'IA==' diff --git a/generator/config/query/bitsAllSet.yaml b/generator/config/query/bitsAllSet.yaml index c11c68660..25e2c6eb8 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,34 +12,27 @@ arguments: type: - int - binData - - array + - array # of int 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: - sub_type: 0 - buffer: !!binary AAAA - position: 0 + - $match: + a: + $bitsAllSet: !bson_binary 'MA==' diff --git a/generator/config/query/bitsAnyClear.yaml b/generator/config/query/bitsAnyClear.yaml index c66614c79..a41260998 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,34 +12,27 @@ arguments: type: - int - binData - - array + - array # of int 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: - sub_type: 0 - buffer: !!binary AAAA - position: 0 + - $match: + a: + $bitsAnyClear: !bson_binary 'MA==' diff --git a/generator/config/query/bitsAnySet.yaml b/generator/config/query/bitsAnySet.yaml index a88f31c46..95aae908a 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,34 +12,27 @@ arguments: type: - int - binData - - array + - array # of int 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: - sub_type: 0 - buffer: !!binary AAAA - position: 0 + - $match: + a: + $bitsAnySet: !bson_binary 'MA==' diff --git a/generator/config/query/box.yaml b/generator/config/query/box.yaml index 327a1e446..14043c4ae 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 17ad6af14..c86215a52 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 2dc04732c..e3677dade 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 dcd3f09d5..13a344613 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 3a8845290..95db9572e 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 0709021e2..5629114cc 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,50 +13,49 @@ 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: - pattern: ^MongoDB - options: '' + !bson_regex '^MongoDB' - $match: company: $eq: - pattern: ^MongoDB - options: '' + !bson_regex '^MongoDB' diff --git a/generator/config/query/exists.yaml b/generator/config/query/exists.yaml index 6c6e69826..00d7ce2cb 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,26 +14,24 @@ 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 666c3ed26..320c84507 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 f3fd8d59c..4df3a43de 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,60 +14,40 @@ 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 c2f81df88..f9f6204d0 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,60 +14,40 @@ 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 2ab982cae..40b18dc99 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 921aead3e..9914a5f34 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 87b3c3351..d8617a7c6 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 199a0c509..67f069416 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,29 +10,23 @@ arguments: - name: value type: - - array + - array # of expression 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: - - - pattern: ^be - options: '' - - - pattern: ^st - options: '' + - !bson_regex '^be' + - !bson_regex '^st' diff --git a/generator/config/query/jsonSchema.yaml b/generator/config/query/jsonSchema.yaml index 6b15db8d9..4c1dca6ad 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 0d1d1debb..f1c996ded 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 fd2b71103..e61d01b03 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 afe7b394b..e95212d23 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 fbe3e1f92..fd467a96f 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 a13d02835..04a187253 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,34 +17,26 @@ 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 + $mod: [4.0, 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 18d89cc4a..a1f5a046b 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 b3353b6ac..89d7f511f 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 725a66f86..72e8e18e9 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,17 +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: 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 7e30c9cc2..4285e4fe7 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,24 +10,21 @@ arguments: - name: value type: - - array + - array # of expression 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 15a5b657d..d1ad7159a 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 246cc00f9..eb2b43cdb 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,12 +22,10 @@ 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: - pattern: ^p.* - options: '' + $not: !bson_regex '^p.*' diff --git a/generator/config/query/or.yaml b/generator/config/query/or.yaml index 2d56663d5..ce2b7603c 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,9 +26,10 @@ 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: @@ -42,5 +43,5 @@ tests: - $divide: - 1 - - $x + - '$x' - 3 diff --git a/generator/config/query/polygon.yaml b/generator/config/query/polygon.yaml index 227362f02..1a46f2bc4 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 7f571dfbf..6773ae0d5 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 a6ebf95be..c7e378ddd 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,24 +11,23 @@ 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: - pattern: 789$ - options: '' + !bson_regex '789$' - - 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: - pattern: ^ABC - options: i + !bson_regex ['^ABC', 'i'] diff --git a/generator/config/query/sampleRate.yaml b/generator/config/query/sampleRate.yaml index 4b9252c87..9995e2d8b 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 f95bd70f4..629de4035 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 f5196b2fe..574ee4508 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 5cf58e389..d8cd7bc86 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,70 +15,74 @@ 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: - $type: - - 2 + # Example uses the short form, the builder always generates the verbose form + # $type: 2 + $type: [2] - $match: zipCode: - $type: - - string + # Example uses the short form, the builder always generates the verbose form + # $type: 'string' + $type: ['string'] - $match: zipCode: - $type: - - 1 + # Example uses the short form, the builder always generates the verbose form + # $type: 1 + $type: [1] - $match: zipCode: - $type: - - double + # Example uses the short form, the builder always generates the verbose form + # $type: 'double' + $type: ['double'] - $match: zipCode: - $type: - - number + # Example uses the short form, the builder always generates the verbose form + # $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: - $type: - - minKey + # Example uses the short form, the builder always generates the verbose form + # $type: 'minKey' + $type: ['minKey'] - $match: zipCode: - $type: - - maxKey + # Example uses the short form, the builder always generates the verbose form + # $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: - $type: - - array + # Example uses the short form, the builder always generates the verbose form + # $type: 'array' + $type: ['array'] diff --git a/generator/config/query/where.yaml b/generator/config/query/where.yaml index 0f24bd0ea..5f5c974ab 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,6 +32,5 @@ 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 c1c51634f..97ef1ce15 100644 --- a/generator/config/schema.json +++ b/generator/config/schema.json @@ -132,57 +132,23 @@ "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" ] } }, @@ -217,12 +183,7 @@ }, "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", @@ -253,123 +214,8 @@ "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 b4ba6abe1..a984b9a39 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 + - string # any|sequential - name: fuzzy optional: true @@ -35,29 +35,30 @@ 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 @@ -68,62 +69,66 @@ 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: @@ -131,12 +136,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 132d69ed4..7a1d9f419 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 + - array # of searchOperator - name: mustNot optional: true type: - searchOperator - - array + - array # of searchOperator - name: should optional: true type: - searchOperator - - array + - array # of searchOperator - name: filter optional: true type: - searchOperator - - array + - array # of searchOperator - 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,16 +54,17 @@ 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: @@ -71,20 +72,21 @@ 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: @@ -92,21 +94,22 @@ 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: @@ -114,21 +117,22 @@ 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: @@ -136,17 +140,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 cbeedfd58..19c804625 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,45 +55,47 @@ 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 - @@ -104,29 +106,30 @@ 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 - @@ -135,18 +138,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 28ed5d361..b3e50c641 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,75 +28,77 @@ 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: - buffer: !!binary WpQnZIsL7r62lYmh + path: 'teammates' + value: !bson_objectId '5a9427648b0beebeb69589a1' + - - 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: 2022-05-04T05:01:08.000Z + path: 'account_created' + value: !bson_utcdatetime '2022-05-04T05:01:08.000+00:00' + - - 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: - sub_type: 4 - buffer: !!binary +sMiYLURTGmEhaK+W33ang== - position: 16 + path: 'uuid' + value: !bson_uuid 'fac32260-b511-4c69-8485-a2be5b7dda9e' + - 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: null + path: 'job_title' + value: ~ diff --git a/generator/config/search/exists.yaml b/generator/config/search/exists.yaml index ad918465a..062e8ba59 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,24 +18,26 @@ 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: @@ -43,12 +45,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 a1c17b678..53dc8cba9 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 + - searchOperator # should be searchCollector encode: object description: | The facet collector groups results by values or ranges in the specified @@ -11,7 +11,7 @@ arguments: - name: facets type: - - object + - object # map of facetDefinition - 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: 1999-07-01T00:00:00.000Z + path: 'released' + origin: !bson_utcdatetime '1999-07-01T00:00:00.000+00:00' 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 2e46c4227..4da121e45 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 + - string # contains | disjoint | intersects | within - name: geometry type: @@ -27,30 +27,22 @@ 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 - @@ -59,59 +51,36 @@ 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 - @@ -120,44 +89,29 @@ 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 - @@ -166,4 +120,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 60ebfc367..1739f1997 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,24 +35,20 @@ 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 - @@ -60,21 +56,20 @@ 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 - @@ -82,30 +77,23 @@ 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 e7a48c90f..cc1aa6c33 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 + - array # of any - name: score optional: true @@ -23,30 +23,31 @@ 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: - - 1977-03-02T02:20:31.000Z - - 1977-03-01T00:00:00.000Z - - 1977-05-06T21:57:35.000Z + - !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' - $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 @@ -56,9 +57,10 @@ 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: @@ -66,19 +68,17 @@ tests: must: - in: - path: name + path: 'name' value: - - james sanchez - - jennifer lawrence + - 'james sanchez' + - 'jennifer lawrence' should: - in: - path: _id + path: '_id' value: - - - buffer: !!binary XKS7zqLdlO5YFipy - - - buffer: !!binary XKS7zqLdlO5YFiqR + - !bson_objectId '5ca4bbcea2dd94ee58162a72' + - !bson_objectId '5ca4bbcea2dd94ee58162a91' - $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 4ae452195..8c4803bdd 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 + - array # of object - 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,9 +38,10 @@ 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: @@ -49,18 +50,16 @@ tests: - moreLikeThis: like: - _id: - buffer: !!binary VzoTlvKTE8qrzkqa + _id: !bson_objectId '573a1396f29313caabce4a9a' genres: - - Crime - - Drama - title: The Godfather + - 'Crime' + - 'Drama' + title: 'The Godfather' mustNot: - equals: - path: _id - value: - buffer: !!binary VzoTlvKTE8qrzkqa + path: '_id' + value: !bson_objectId '573a1396f29313caabce4a9a' - $limit: 5 - @@ -69,9 +68,10 @@ 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,18 +80,16 @@ tests: - moreLikeThis: like: - _id: - buffer: !!binary VzoTlvKTE8qrzkqa + _id: !bson_objectId '573a1396f29313caabce4a9a' genres: - - Crime - - Drama - title: The Godfather + - 'Crime' + - 'Drama' + title: 'The Godfather' mustNot: - equals: - path: _id - value: - buffer: !!binary VzoTlPKTE8qrzenv + path: '_id' + value: !bson_objectId '573a1394f29313caabcde9ef' - $limit: 10 - diff --git a/generator/config/search/near.yaml b/generator/config/search/near.yaml index f798d42af..bd4119cf9 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,17 +46,18 @@ 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: 1915-09-13T00:00:00.000Z + path: 'released' + origin: !bson_utcdatetime '1915-09-13T00:00:00.000+00:00' pivot: 7776000000 - $limit: 3 @@ -66,21 +67,22 @@ 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 - @@ -89,27 +91,28 @@ 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 - @@ -118,4 +121,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 291310fb4..4d9b75c4e 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 + - array # of string - 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,18 +48,19 @@ 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 - @@ -67,34 +68,36 @@ 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 - @@ -103,4 +106,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 bcb63a5eb..8202771c9 100644 --- a/generator/config/search/queryString.yaml +++ b/generator/config/search/queryString.yaml @@ -1,10 +1,11 @@ # $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 @@ -14,16 +15,20 @@ 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 613095754..f42c69176 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,14 +67,15 @@ 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 @@ -84,17 +85,18 @@ 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: 2010-01-01T00:00:00.000Z - lt: 2015-01-01T00:00:00.000Z + path: 'released' + gt: !bson_utcdatetime '2010-01-01T00:00:00.000Z' + lt: !bson_utcdatetime '2015-01-01T00:00:00.000Z' - $limit: 5 - @@ -102,33 +104,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: - buffer: !!binary VzoTlvKTE8qrzkqa - lte: - buffer: !!binary VzoTlvKTE8qrzkrn + path: '_id' + gte: !bson_objectId '573a1396f29313caabce4a9a' + lte: !bson_objectId '573a1396f29313caabce4ae7' - $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 2a5d5621d..869ffabde 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 13029c485..dbd48cdd0 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 + - string # "any" | "all" - 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,16 +69,17 @@ 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 @@ -89,16 +90,17 @@ 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 @@ -109,18 +111,19 @@ 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 - @@ -129,18 +132,19 @@ 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 - @@ -149,18 +153,19 @@ 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 - @@ -169,20 +174,21 @@ 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 fd02aed2c..d17fb4803 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,15 +42,16 @@ 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 b17cb8d4f..e98f5de18 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,41 +16,42 @@ 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: - $sum: - - $homework + # The example renders a single value, but the builder generates an array for consistency + # $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: @@ -59,6 +60,5 @@ tests: $addFields: homework: $concatArrays: - - $homework - - - - 7 + - '$homework' + - [7] diff --git a/generator/config/stage/bucket.yaml b/generator/config/stage/bucket.yaml index 6db170c3a..0cd65feac 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 + - expression # mainly fieldPath 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 + - array # of expression 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 + - object # of Accumulator 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,19 +42,14 @@ 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 @@ -62,52 +57,45 @@ 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 153d4eec0..73775fde8 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 + - object # of Accumulator 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 40987377a..be413ef5d 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 7bf870bd3..208129346 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 f990e2274..26cbbc470 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 + - object # empty object optional: true - name: queryExecStats type: - - object + - object # empty 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 05fc7301f..a0fa3ba57 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,26 +16,12 @@ 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/#examples + name: 'Example' + link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/#example' pipeline: - $match: score: $gt: 80 - - $count: passing_scores - schema: - scores: - _id: - types: - - - bsonType: Number - subject: - types: - - - bsonType: String - score: - types: - - - bsonType: Number + $count: 'passing_scores' diff --git a/generator/config/stage/currentOp.yaml b/generator/config/stage/currentOp.yaml index 0cb2cb1f0..024c71318 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 7c6d58ee7..46ccbd6dd 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 + - string # field name 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 + - array # of string 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: - - 2021-05-18T00:00:00.000Z - - 2021-05-18T08:00:00.000Z + - !bson_utcdatetime '2021-05-18T00:00:00.000Z' + - !bson_utcdatetime '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 373c3550c..666468da8 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 + - resolvesToArray # of object description: | $documents accepts any valid expression that resolves to an array of objects. This includes: - system variables, such as $$NOW or $$SEARCH_META @@ -19,38 +19,35 @@ 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 695422b7e..013163c2a 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,39 +14,38 @@ 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 04d2c1f8b..2c98fac5c 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 + - object # of expression - string optional: true description: | @@ -20,7 +20,7 @@ arguments: - name: partitionByFields type: - - array + - array # of string 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 + - object # of object{value:expression} or object{method:string}> 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 c49a3b874..4967a0823 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 ed565216e..ae220620b 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 39bacc77e..a4bae60c2 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: null + _id: ~ 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: 2014-01-01T00:00:00.000Z - $lt: 2015-01-01T00:00:00.000Z + $gte: !bson_utcdatetime '2014-01-01' + $lt: !bson_utcdatetime '2015-01-01' - $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: null + _id: ~ 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 a8dab4930..178b209d8 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 0bf5b649c..fff391a01 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 729f1ad6f..50dccc30e 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 6e8c66cac..f767f0d04 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,15 +14,16 @@ 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 5ffa1e70f..afc4f6d05 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 185ef98d3..efb56de05 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,25 +23,26 @@ 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 81a0f9bdf..b73770e47 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 + - object # of expression 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 95ed110ee..ab0081fd0 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: null + _id: ~ count: $sum: 1 diff --git a/generator/config/stage/merge.yaml b/generator/config/stage/merge.yaml index 21d72d7a0..766092d82 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 + - array # of string 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: 2019-05-07T00:00:00.000Z - $lt: 2019-05-08T00:00:00.000Z + $gte: !bson_utcdatetime '2019-05-07' + $lt: !bson_utcdatetime '2019-05-08' - $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 3264de0f8..0c3597fdf 100644 --- a/generator/config/stage/out.yaml +++ b/generator/config/stage/out.yaml @@ -1,14 +1,13 @@ # $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 @@ -16,26 +15,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 ec7099a58..995caa74e 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 3ef209a56..bde7c420d 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 + variadic: object # XXX: This should somehow allow explicit typings for { fieldName: 1|0 } 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 134e2e3b7..07698119c 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 d7d31aad6..4de474e00 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,36 +25,38 @@ 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: @@ -66,4 +68,4 @@ tests: email: '' cell: '' home: '' - - $$ROOT + - '$$ROOT' diff --git a/generator/config/stage/replaceWith.yaml b/generator/config/stage/replaceWith.yaml index ddb4d29de..10c5fa3a2 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,40 +25,42 @@ 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: @@ -69,4 +71,4 @@ tests: email: '' cell: '' home: '' - - $$ROOT + - '$$ROOT' diff --git a/generator/config/stage/sample.yaml b/generator/config/stage/sample.yaml index ed5f52bcb..757382aaf 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 22e2a71d3..44756ce23 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,6 +27,8 @@ 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. @@ -90,14 +92,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: 2011-09-01T00:00:00.000Z + path: 'released' + origin: !bson_utcdatetime '2011-09-01T00:00:00.000+00:00' pivot: 7776000000 - $project: @@ -111,19 +113,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: 2010-01-01T00:00:00.000Z - lt: 2015-01-01T00:00:00.000Z + path: 'released' + gt: !bson_utcdatetime '2010-01-01T00:00:00.000Z' + lt: !bson_utcdatetime '2015-01-01T00:00:00.000Z' sort: released: -1 - @@ -134,13 +136,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 @@ -152,17 +154,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 @@ -171,65 +173,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: 2011-09-01T00:00:00.000Z + path: 'released' + origin: !bson_utcdatetime '2011-09-01T00:00:00.000+00:00' 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 - @@ -237,14 +239,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: @@ -257,7 +259,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 3fa1c483e..a7d92c272 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,6 +23,7 @@ arguments: - string description: | Name of the Atlas Search index to use. If omitted, defaults to default. + - name: count optional: true @@ -32,97 +33,100 @@ 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: 2000-01-01T00:00:00.000Z - lte: 2015-01-31T00:00:00.000Z + path: 'released' + gte: !bson_utcdatetime '2000-01-01T00:00:00.000Z' + lte: !bson_utcdatetime '2015-01-31T00:00:00.000Z' facets: yearFacet: - type: date - path: released + type: 'date' + path: 'released' boundaries: - - 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 + - !bson_utcdatetime '2000-01-01' + - !bson_utcdatetime '2005-01-01' + - !bson_utcdatetime '2010-01-01' + - !bson_utcdatetime '2015-01-01' + 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: 2000-01-01T00:00:00.000Z - lte: 2015-01-31T00:00:00.000Z + path: 'released' + gte: !bson_utcdatetime '2000-01-01T00:00:00.000Z' + lte: !bson_utcdatetime '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 41531fdb1..a5861aa29 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,41 +15,42 @@ 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: - $sum: - - $homework + # The $sum expression is always build as an array, even if the value is an array field name + # $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: @@ -58,15 +59,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 74c053361..6f86472d7 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,128 +30,115 @@ 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 9a9f70e5d..2f298ca0f 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 abdf2163a..2128fe226 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 89d3e4944..d35e23b63 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 0084d9a63..a32d7aff4 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,11 +13,13 @@ 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 e1622a014..eafa44110 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,23 +57,27 @@ 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 a3a0a6bda..cef9cdd6d 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,26 +15,28 @@ 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: - - $unset: - - copies + # The example in the docs uses the short syntax whereas + # the aggregation builder always uses the equivalent array syntax. + # $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 def764b9c..a1f93edbc 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,59 +31,65 @@ 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 d11bf4777..bcd3c008a 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 + - array # of numbers description: | Array of numbers that represent the query vector. The number type must match the indexed field value type. - @@ -53,19 +53,17 @@ 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 + index: 'vector_index' + path: 'plot_embedding' + queryVector: [-0.0016261312, -0.028070757, -0.011342932] # skip other numbers, not relevant to the test numCandidates: 150 limit: 10 - @@ -74,24 +72,22 @@ 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 + queryVector: [0.02421053, -0.022372592, -0.006231137] # skip other numbers, not relevant to the test numCandidates: 150 limit: 10 - @@ -101,19 +97,17 @@ 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 + index: 'vector_index' + path: 'plot_embedding' + queryVector: [-0.006954097, -0.009932499, -0.001311474] # skip other numbers, not relevant to the test exact: true limit: 10 - @@ -122,4 +116,4 @@ tests: plot: 1 title: 1 score: - $meta: vectorSearchScore + $meta: 'vectorSearchScore' From 07cd9fcdabc46e3e10f42bfa205a5366e878f239 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 22 May 2025 12:01:48 +0200 Subject: [PATCH 04/16] run yamlfix --- generator/config/.yamlfix.toml | 8 + generator/config/accumulator/accumulator.yaml | 227 +++++---- generator/config/accumulator/addToSet.yaml | 55 +-- generator/config/accumulator/avg.yaml | 64 ++- generator/config/accumulator/bottom.yaml | 81 ++-- generator/config/accumulator/bottomN.yaml | 136 +++--- generator/config/accumulator/count.yaml | 44 +- .../config/accumulator/covariancePop.yaml | 53 +- .../config/accumulator/covarianceSamp.yaml | 53 +- generator/config/accumulator/denseRank.yaml | 46 +- generator/config/accumulator/derivative.yaml | 67 ++- .../config/accumulator/documentNumber.yaml | 24 +- .../config/accumulator/expMovingAvg.yaml | 93 ++-- generator/config/accumulator/first.yaml | 62 ++- generator/config/accumulator/firstN.yaml | 199 ++++---- generator/config/accumulator/integral.yaml | 62 ++- generator/config/accumulator/last.yaml | 62 ++- generator/config/accumulator/lastN.yaml | 142 +++--- generator/config/accumulator/linearFill.yaml | 53 +- generator/config/accumulator/locf.yaml | 29 +- generator/config/accumulator/max.yaml | 65 ++- generator/config/accumulator/maxN.yaml | 117 +++-- generator/config/accumulator/median.yaml | 81 ++-- .../config/accumulator/mergeObjects.yaml | 29 +- generator/config/accumulator/min.yaml | 55 +-- generator/config/accumulator/minN.yaml | 117 +++-- generator/config/accumulator/percentile.yaml | 171 +++---- generator/config/accumulator/push.yaml | 76 ++- generator/config/accumulator/rank.yaml | 46 +- generator/config/accumulator/shift.yaml | 103 ++-- generator/config/accumulator/stdDevPop.yaml | 53 +- generator/config/accumulator/stdDevSamp.yaml | 58 ++- generator/config/accumulator/sum.yaml | 77 ++- generator/config/accumulator/top.yaml | 82 ++-- generator/config/accumulator/topN.yaml | 137 +++--- generator/config/expression/abs.yaml | 29 +- generator/config/expression/acos.yaml | 39 +- generator/config/expression/acosh.yaml | 33 +- generator/config/expression/add.yaml | 57 +-- .../config/expression/allElementsTrue.yaml | 29 +- generator/config/expression/and.yaml | 51 +- .../config/expression/anyElementTrue.yaml | 29 +- generator/config/expression/arrayElemAt.yaml | 44 +- .../config/expression/arrayToObject.yaml | 69 ++- generator/config/expression/asin.yaml | 39 +- generator/config/expression/asinh.yaml | 33 +- generator/config/expression/atan.yaml | 39 +- generator/config/expression/atan2.yaml | 44 +- generator/config/expression/atanh.yaml | 33 +- generator/config/expression/avg.yaml | 41 +- generator/config/expression/binarySize.yaml | 29 +- generator/config/expression/bitAnd.yaml | 49 +- generator/config/expression/bitNot.yaml | 25 +- generator/config/expression/bitOr.yaml | 49 +- generator/config/expression/bitXor.yaml | 31 +- generator/config/expression/bsonSize.yaml | 69 ++- generator/config/expression/case.yaml | 24 +- generator/config/expression/ceil.yaml | 29 +- generator/config/expression/cmp.yaml | 40 +- generator/config/expression/concat.yaml | 31 +- generator/config/expression/concatArrays.yaml | 29 +- generator/config/expression/cond.yaml | 51 +- generator/config/expression/convert.yaml | 132 +++-- generator/config/expression/cos.yaml | 36 +- generator/config/expression/cosh.yaml | 31 +- generator/config/expression/dateAdd.yaml | 231 +++++---- generator/config/expression/dateDiff.yaml | 196 ++++---- .../config/expression/dateFromParts.yaml | 197 ++++---- .../config/expression/dateFromString.yaml | 130 +++-- generator/config/expression/dateSubtract.yaml | 237 +++++---- generator/config/expression/dateToParts.yaml | 75 ++- generator/config/expression/dateToString.yaml | 138 +++--- generator/config/expression/dateTrunc.yaml | 123 +++-- generator/config/expression/dayOfMonth.yaml | 46 +- generator/config/expression/dayOfWeek.yaml | 46 +- generator/config/expression/dayOfYear.yaml | 46 +- .../config/expression/degreesToRadians.yaml | 37 +- generator/config/expression/divide.yaml | 40 +- generator/config/expression/eq.yaml | 40 +- generator/config/expression/exp.yaml | 28 +- generator/config/expression/filter.yaml | 158 +++--- generator/config/expression/first.yaml | 21 +- generator/config/expression/firstN.yaml | 71 ++- generator/config/expression/floor.yaml | 25 +- generator/config/expression/function.yaml | 121 +++-- generator/config/expression/getField.yaml | 99 ++-- generator/config/expression/gt.yaml | 40 +- generator/config/expression/gte.yaml | 40 +- generator/config/expression/hour.yaml | 46 +- generator/config/expression/ifNull.yaml | 53 +- generator/config/expression/in.yaml | 44 +- generator/config/expression/indexOfArray.yaml | 72 ++- generator/config/expression/indexOfBytes.yaml | 76 ++- generator/config/expression/indexOfCP.yaml | 76 ++- generator/config/expression/isArray.yaml | 47 +- generator/config/expression/isNumber.yaml | 117 ++--- generator/config/expression/isoDayOfWeek.yaml | 50 +- generator/config/expression/isoWeek.yaml | 50 +- generator/config/expression/isoWeekYear.yaml | 46 +- generator/config/expression/last.yaml | 21 +- generator/config/expression/lastN.yaml | 75 ++- generator/config/expression/let.yaml | 68 ++- generator/config/expression/literal.yaml | 13 +- generator/config/expression/ln.yaml | 29 +- generator/config/expression/log.yaml | 49 +- generator/config/expression/log10.yaml | 32 +- generator/config/expression/lt.yaml | 40 +- generator/config/expression/lte.yaml | 40 +- generator/config/expression/ltrim.yaml | 48 +- generator/config/expression/map.yaml | 120 +++-- generator/config/expression/max.yaml | 41 +- generator/config/expression/maxN.yaml | 42 +- generator/config/expression/median.yaml | 54 +-- generator/config/expression/mergeObjects.yaml | 54 +-- generator/config/expression/meta.yaml | 53 +- generator/config/expression/millisecond.yaml | 46 +- generator/config/expression/min.yaml | 41 +- generator/config/expression/minN.yaml | 42 +- generator/config/expression/minute.yaml | 46 +- generator/config/expression/mod.yaml | 38 +- generator/config/expression/month.yaml | 46 +- generator/config/expression/multiply.yaml | 39 +- generator/config/expression/ne.yaml | 40 +- generator/config/expression/not.yaml | 34 +- .../config/expression/objectToArray.yaml | 57 +-- generator/config/expression/or.yaml | 43 +- generator/config/expression/percentile.yaml | 71 ++- generator/config/expression/pow.yaml | 36 +- .../config/expression/radiansToDegrees.yaml | 31 +- generator/config/expression/rand.yaml | 66 ++- generator/config/expression/range.yaml | 61 ++- generator/config/expression/reduce.yaml | 228 ++++----- generator/config/expression/regexFind.yaml | 99 ++-- generator/config/expression/regexFindAll.yaml | 163 +++---- generator/config/expression/regexMatch.yaml | 127 +++-- generator/config/expression/replaceAll.yaml | 61 ++- generator/config/expression/replaceOne.yaml | 61 ++- generator/config/expression/reverseArray.yaml | 29 +- generator/config/expression/round.yaml | 68 ++- generator/config/expression/rtrim.yaml | 48 +- generator/config/expression/second.yaml | 46 +- .../config/expression/setDifference.yaml | 48 +- generator/config/expression/setEquals.yaml | 35 +- generator/config/expression/setField.yaml | 171 +++---- .../config/expression/setIntersection.yaml | 61 ++- generator/config/expression/setIsSubset.yaml | 41 +- generator/config/expression/setUnion.yaml | 35 +- generator/config/expression/sin.yaml | 36 +- generator/config/expression/sinh.yaml | 31 +- generator/config/expression/size.yaml | 41 +- generator/config/expression/slice.yaml | 65 ++- generator/config/expression/sortArray.yaml | 182 ++++--- generator/config/expression/split.yaml | 70 ++- generator/config/expression/sqrt.yaml | 53 +- generator/config/expression/stdDevPop.yaml | 26 +- generator/config/expression/stdDevSamp.yaml | 11 +- generator/config/expression/strLenBytes.yaml | 25 +- generator/config/expression/strLenCP.yaml | 25 +- generator/config/expression/strcasecmp.yaml | 36 +- generator/config/expression/substr.yaml | 63 ++- generator/config/expression/substrBytes.yaml | 91 ++-- generator/config/expression/substrCP.yaml | 91 ++-- generator/config/expression/subtract.yaml | 85 ++-- generator/config/expression/sum.yaml | 43 +- generator/config/expression/switch.yaml | 105 ++-- generator/config/expression/tan.yaml | 36 +- generator/config/expression/tanh.yaml | 31 +- generator/config/expression/toBool.yaml | 56 +-- generator/config/expression/toDate.yaml | 28 +- generator/config/expression/toDecimal.yaml | 23 +- generator/config/expression/toDouble.yaml | 31 +- .../config/expression/toHashedIndexKey.yaml | 37 +- generator/config/expression/toInt.yaml | 23 +- generator/config/expression/toLong.yaml | 28 +- generator/config/expression/toLower.yaml | 27 +- generator/config/expression/toObjectId.yaml | 28 +- generator/config/expression/toString.yaml | 28 +- generator/config/expression/toUpper.yaml | 27 +- generator/config/expression/trim.yaml | 48 +- generator/config/expression/trunc.yaml | 46 +- generator/config/expression/tsIncrement.yaml | 51 +- generator/config/expression/tsSecond.yaml | 41 +- generator/config/expression/type.yaml | 23 +- generator/config/expression/unsetField.yaml | 86 ++-- generator/config/expression/week.yaml | 46 +- generator/config/expression/year.yaml | 46 +- generator/config/expression/zip.yaml | 142 +++--- generator/config/query/all.yaml | 61 ++- generator/config/query/and.yaml | 71 ++- generator/config/query/bitsAllClear.yaml | 55 +-- generator/config/query/bitsAllSet.yaml | 55 +-- generator/config/query/bitsAnyClear.yaml | 55 +-- generator/config/query/bitsAnySet.yaml | 55 +-- generator/config/query/box.yaml | 9 +- generator/config/query/center.yaml | 9 +- generator/config/query/centerSphere.yaml | 9 +- generator/config/query/comment.yaml | 40 +- generator/config/query/elemMatch.yaml | 105 ++-- generator/config/query/eq.yaml | 89 ++-- generator/config/query/exists.yaml | 55 +-- generator/config/query/expr.yaml | 70 ++- generator/config/query/geoIntersects.yaml | 81 ++-- generator/config/query/geoWithin.yaml | 81 ++-- generator/config/query/geometry.yaml | 25 +- generator/config/query/gt.yaml | 23 +- generator/config/query/gte.yaml | 23 +- generator/config/query/in.yaml | 43 +- generator/config/query/jsonSchema.yaml | 57 ++- generator/config/query/lt.yaml | 23 +- generator/config/query/lte.yaml | 23 +- generator/config/query/maxDistance.yaml | 9 +- generator/config/query/minDistance.yaml | 11 +- generator/config/query/mod.yaml | 66 +-- generator/config/query/ne.yaml | 23 +- generator/config/query/near.yaml | 65 ++- generator/config/query/nearSphere.yaml | 63 ++- generator/config/query/nin.yaml | 40 +- generator/config/query/nor.yaml | 82 ++-- generator/config/query/not.yaml | 39 +- generator/config/query/or.yaml | 65 ++- generator/config/query/polygon.yaml | 9 +- generator/config/query/rand.yaml | 32 +- generator/config/query/regex.yaml | 42 +- generator/config/query/sampleRate.yaml | 30 +- generator/config/query/size.yaml | 23 +- generator/config/query/text.yaml | 188 ++++---- generator/config/query/type.yaml | 123 +++-- generator/config/query/where.yaml | 51 +- generator/config/schema.json | 190 +++++++- generator/config/search/autocomplete.yaml | 244 ++++------ generator/config/search/compound.yaml | 255 +++++----- generator/config/search/embeddedDocument.yaml | 252 +++++----- generator/config/search/equals.yaml | 166 +++---- generator/config/search/exists.yaml | 82 ++-- generator/config/search/facet.yaml | 82 ++-- generator/config/search/geoShape.yaml | 182 +++---- generator/config/search/geoWithin.yaml | 168 +++---- generator/config/search/in.yaml | 143 +++--- generator/config/search/moreLikeThis.yaml | 156 +++--- generator/config/search/near.yaml | 207 ++++---- generator/config/search/phrase.yaml | 177 +++---- generator/config/search/queryString.yaml | 41 +- generator/config/search/range.yaml | 229 ++++----- generator/config/search/regex.yaml | 57 +-- generator/config/search/text.yaml | 326 ++++++------- generator/config/search/wildcard.yaml | 89 ++-- generator/config/stage/addFields.yaml | 95 ++-- generator/config/stage/bucket.yaml | 183 +++---- generator/config/stage/bucketAuto.yaml | 68 ++- generator/config/stage/changeStream.yaml | 105 ++-- .../stage/changeStreamSplitLargeEvent.yaml | 12 +- generator/config/stage/collStats.yaml | 88 ++-- generator/config/stage/count.yaml | 30 +- generator/config/stage/currentOp.yaml | 89 ++-- generator/config/stage/densify.yaml | 87 ++-- generator/config/stage/documents.yaml | 78 ++- generator/config/stage/facet.yaml | 73 ++- generator/config/stage/fill.yaml | 186 ++++--- generator/config/stage/geoNear.yaml | 282 +++++------ generator/config/stage/graphLookup.yaml | 182 ++++--- generator/config/stage/group.yaml | 207 ++++---- generator/config/stage/indexStats.yaml | 12 +- generator/config/stage/limit.yaml | 19 +- generator/config/stage/listLocalSessions.yaml | 67 ++- .../config/stage/listSampledQueries.yaml | 34 +- generator/config/stage/listSearchIndexes.yaml | 62 ++- generator/config/stage/listSessions.yaml | 68 ++- generator/config/stage/lookup.yaml | 283 +++++------ generator/config/stage/match.yaml | 54 +-- generator/config/stage/merge.yaml | 312 ++++++------ generator/config/stage/out.yaml | 56 +-- generator/config/stage/planCacheStats.yaml | 27 +- generator/config/stage/project.yaml | 209 ++++---- generator/config/stage/redact.yaml | 77 ++- generator/config/stage/replaceRoot.yaml | 107 ++--- generator/config/stage/replaceWith.yaml | 110 ++--- generator/config/stage/sample.yaml | 25 +- generator/config/stage/search.yaml | 452 ++++++++---------- generator/config/stage/searchMeta.yaml | 227 ++++----- generator/config/stage/set.yaml | 107 ++--- generator/config/stage/setWindowFields.yaml | 262 +++++----- .../config/stage/shardedDataDistribution.yaml | 12 +- generator/config/stage/skip.yaml | 19 +- generator/config/stage/sort.yaml | 50 +- generator/config/stage/sortByCount.yaml | 24 +- generator/config/stage/unionWith.yaml | 121 ++--- generator/config/stage/unset.yaml | 52 +- generator/config/stage/unwind.yaml | 143 +++--- generator/config/stage/vectorSearch.yaml | 209 ++++---- 289 files changed, 10005 insertions(+), 11885 deletions(-) create mode 100644 generator/config/.yamlfix.toml diff --git a/generator/config/.yamlfix.toml b/generator/config/.yamlfix.toml new file mode 100644 index 000000000..e4b1e02bb --- /dev/null +++ b/generator/config/.yamlfix.toml @@ -0,0 +1,8 @@ +allow_duplicate_keys = false +comments_min_spaces_from_content = 1 +sequence_style = "block_style" +indent_mapping = 4 +indent_offset = 4 +indent_sequence = 6 +none_representation = "~" +explicit_start = false diff --git a/generator/config/accumulator/accumulator.yaml b/generator/config/accumulator/accumulator.yaml index 9cfdb6b53..9757d28f7 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 @@ -8,125 +8,114 @@ description: | Defines a custom accumulator function. New in MongoDB 4.4. arguments: - - - name: init - type: - - javascript - description: | - Function used to initialize the state. The init function receives its arguments from the initArgs array expression. You can specify the function definition as either BSON type Code or String. - - - name: initArgs - type: - - resolvesToArray - optional: true - description: | - Arguments passed to the init function. - - - name: accumulate - type: - - javascript - description: | - Function used to accumulate documents. The accumulate function receives its arguments from the current state and accumulateArgs array expression. The result of the accumulate function becomes the new state. You can specify the function definition as either BSON type Code or String. - - - name: accumulateArgs - type: - - resolvesToArray - description: | - Arguments passed to the accumulate function. You can use accumulateArgs to specify what field value(s) to pass to the accumulate function. - - - name: merge - type: - - javascript - description: | - Function used to merge two internal states. merge must be either a String or Code BSON type. merge returns the combined result of the two merged states. For information on when the merge function is called, see Merge Two States with $merge. - - - name: finalize - type: - - javascript - optional: true - description: | - Function used to update the result of the accumulation. - - - name: lang - type: - - string - description: | - The language used in the $accumulator code. - + - name: init + type: + - javascript + description: | + Function used to initialize the state. The init function receives its arguments from the initArgs array expression. You can specify the function definition as either BSON type Code or String. + - name: initArgs + type: + - resolvesToArray + optional: true + description: | + Arguments passed to the init function. + - name: accumulate + type: + - javascript + description: | + Function used to accumulate documents. The accumulate function receives its arguments from the current state and accumulateArgs array expression. The result of the accumulate function becomes the new state. You can specify the function definition as either BSON type Code or String. + - name: accumulateArgs + type: + - resolvesToArray + description: | + Arguments passed to the accumulate function. You can use accumulateArgs to specify what field value(s) to pass to the accumulate function. + - name: merge + type: + - javascript + description: | + Function used to merge two internal states. merge must be either a String or Code BSON type. merge returns the combined result of the two merged states. For information on when the merge function is called, see Merge Two States with $merge. + - name: finalize + type: + - javascript + optional: true + description: | + Function used to update the result of the accumulation. + - name: lang + type: + - 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' - pipeline: - - - $group: - _id: '$author' - avgCopies: - $accumulator: - init: - $code: |- - function() { - return { count: 0, sum: 0 } + - 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 + avgCopies: + $accumulator: + init: + $code: |- + function() { + return { count: 0, sum: 0 } + } + accumulate: + $code: |- + function(state, numCopies) { + return { count: state.count + 1, sum: state.sum + numCopies } + } + accumulateArgs: + - $copies + merge: + $code: |- + function(state1, state2) { + return { + count: state1.count + state2.count, + sum: state1.sum + state2.sum } - accumulate: - $code: |- - function(state, numCopies) { - return { count: state.count + 1, sum: state.sum + numCopies } + } + finalize: + $code: |- + function(state) { + return (state.sum / state.count) + } + lang: js + - 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 + restaurants: + $accumulator: + init: + $code: |- + function(city, userProfileCity) { + return { max: city === userProfileCity ? 3 : 1, restaurants: [] } + } + initArgs: + - $city + - Bettles + accumulate: + $code: |- + function(state, restaurantName) { + if (state.restaurants.length < state.max) { + state.restaurants.push(restaurantName); } - accumulateArgs: [ "$copies" ] - merge: - $code: |- - function(state1, state2) { - return { - count: state1.count + state2.count, - sum: state1.sum + state2.sum - } + return state; + } + accumulateArgs: + - $name + merge: + $code: |- + function(state1, state2) { + return { + max: state1.max, + restaurants: state1.restaurants.concat(state2.restaurants).slice(0, state1.max) } - finalize: - $code: |- - function(state) { - return (state.sum / state.count) - } - lang: 'js' - - - - 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' - restaurants: - $accumulator: - init: - $code: |- - function(city, userProfileCity) { - return { max: city === userProfileCity ? 3 : 1, restaurants: [] } - } - initArgs: - - '$city' - - 'Bettles' - accumulate: - $code: |- - function(state, restaurantName) { - if (state.restaurants.length < state.max) { - state.restaurants.push(restaurantName); - } - return state; - } - accumulateArgs: ['$name'] - merge: - $code: |- - function(state1, state2) { - return { - max: state1.max, - restaurants: state1.restaurants.concat(state2.restaurants).slice(0, state1.max) - } - } - finalize: - $code: |- - function(state) { - return state.restaurants - } - lang: 'js' + } + finalize: + $code: |- + function(state) { + return state.restaurants + } + lang: js diff --git a/generator/config/accumulator/addToSet.yaml b/generator/config/accumulator/addToSet.yaml index 9566899eb..5332682d8 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 @@ -9,39 +9,34 @@ description: | Returns an array of unique expression values for each group. Order of the array elements is undefined. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - expression - + - 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' - pipeline: - - $group: + - name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--group-stage + pipeline: + - $group: _id: day: $dayOfYear: - date: '$date' + date: $date year: $year: - date: '$date' + date: $date itemsSold: - $addToSet: '$item' - - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--setwindowfields-stage' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - cakeTypesForState: - $addToSet: '$type' - window: - documents: - - 'unbounded' - - 'current' + $addToSet: $item + - name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--setwindowfields-stage + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + cakeTypesForState: + $addToSet: $type + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/avg.yaml b/generator/config/accumulator/avg.yaml index 3777bbf98..052e44eb3 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 @@ -9,37 +9,33 @@ description: | Returns an average of numerical values. Ignores non-numeric values. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - resolvesToNumber + - name: expression + type: + - resolvesToNumber tests: - - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--group-stage' - pipeline: - - $group: - _id: '$item' - avgAmount: - $avg: - $multiply: - - '$price' - - '$quantity' - avgQuantity: - $avg: '$quantity' - - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--setwindowfields-stage' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - averageQuantityForState: - $avg: '$quantity' - window: - documents: - - 'unbounded' - - 'current' + - name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--group-stage + pipeline: + - $group: + _id: $item + avgAmount: + $avg: + $multiply: + - $price + - $quantity + avgQuantity: + $avg: $quantity + - name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--setwindowfields-stage + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + averageQuantityForState: + $avg: $quantity + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/bottom.yaml b/generator/config/accumulator/bottom.yaml index 1e363d193..d2455dd36 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 @@ -9,47 +9,40 @@ description: | Returns the bottom element within a group according to the specified sort order. New in MongoDB 5.2: Available in the $group and $setWindowFields stages. arguments: - - - name: sortBy - type: - - sortBy - description: | - Specifies the order of results, with syntax similar to $sort. - - - name: output - type: - - expression - description: | - Represents the output for each element in the group and can be any expression. + - name: sortBy + type: + - sortBy + description: | + Specifies the order of results, with syntax similar to $sort. + - name: output + type: + - expression + description: | + 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' - pipeline: - - - $match: - gameId: 'G1' - - - $group: - _id: '$gameId' - playerId: - $bottom: - output: - - '$playerId' - - '$score' - sortBy: - score: -1 - - - 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' - playerId: - $bottom: - output: - - '$playerId' - - '$score' - sortBy: - score: -1 + - name: Find the Bottom Score + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/#find-the-bottom-score + pipeline: + - $match: + gameId: G1 + - $group: + _id: $gameId + playerId: + $bottom: + output: + - $playerId + - $score + sortBy: + score: -1 + - 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 + playerId: + $bottom: + output: + - $playerId + - $score + sortBy: + score: -1 diff --git a/generator/config/accumulator/bottomN.yaml b/generator/config/accumulator/bottomN.yaml index 355d8e09a..c94ad42ac 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 @@ -10,76 +10,66 @@ description: | New in MongoDB 5.2. Available in the $group and $setWindowFields stages. arguments: - - - name: 'n' - type: - - resolvesToInt - description: | - Limits the number of results per group and has to be a positive integral expression that is either a constant or depends on the _id value for $group. - - - name: sortBy - type: - - sortBy - description: | - Specifies the order of results, with syntax similar to $sort. - - - name: output - type: - - expression - description: | - Represents the output for each element in the group and can be any expression. + - name: n + type: + - resolvesToInt + description: | + Limits the number of results per group and has to be a positive integral expression that is either a constant or depends on the _id value for $group. + - name: sortBy + type: + - sortBy + description: | + Specifies the order of results, with syntax similar to $sort. + - name: output + type: + - expression + description: | + 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' - pipeline: - - - $match: - gameId: 'G1' - - - $group: - _id: '$gameId' - playerId: - $bottomN: - output: - - '$playerId' - - '$score' - sortBy: - score: -1 - n: 3 - - - 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' - playerId: - $bottomN: - output: - - '$playerId' - - '$score' - sortBy: - score: -1 - n: 3 - - - 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' - gamescores: - $bottomN: - output: '$score' - n: - $cond: - if: - $eq: - - '$gameId' - - 'G2' - then: 1 - else: 3 - sortBy: - score: -1 + - 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 + - $group: + _id: $gameId + playerId: + $bottomN: + output: + - $playerId + - $score + sortBy: + score: -1 + n: 3 + - 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 + playerId: + $bottomN: + output: + - $playerId + - $score + sortBy: + score: -1 + n: 3 + - 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 + gamescores: + $bottomN: + output: $score + n: + $cond: + if: + $eq: + - $gameId + - G2 + then: 1 + else: 3 + sortBy: + score: -1 diff --git a/generator/config/accumulator/count.yaml b/generator/config/accumulator/count.yaml index d9819056d..113bc35ba 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 @@ -10,28 +10,24 @@ description: | Distinct from the $count pipeline stage. 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' - pipeline: - - - $group: - _id: '$state' + - 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 + countNumberOfDocumentsForState: + $count: {} + - 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 + sortBy: + orderDate: 1 + output: countNumberOfDocumentsForState: $count: {} - - - 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' - sortBy: - orderDate: 1 - output: - countNumberOfDocumentsForState: - $count: {} - window: - documents: - - 'unbounded' - - 'current' + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/covariancePop.yaml b/generator/config/accumulator/covariancePop.yaml index b43a24022..66777413c 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 @@ -8,34 +8,29 @@ description: | Returns the population covariance of two numeric expressions. New in MongoDB 5.0. arguments: - - - name: expression1 - type: - - resolvesToNumber - - - name: expression2 - type: - - resolvesToNumber + - name: expression1 + type: + - resolvesToNumber + - name: expression2 + type: + - resolvesToNumber tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/covariancePop/#example' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - covariancePopForState: - $covariancePop: - - + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/covariancePop/#example + pipeline: + - $setWindowFields: + 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' - window: - documents: - - 'unbounded' - - 'current' + - $year: + date: $orderDate + - $quantity + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/covarianceSamp.yaml b/generator/config/accumulator/covarianceSamp.yaml index b6cc529af..84da2ccba 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 @@ -8,34 +8,29 @@ description: | Returns the sample covariance of two numeric expressions. New in MongoDB 5.0. arguments: - - - name: expression1 - type: - - resolvesToNumber - - - name: expression2 - type: - - resolvesToNumber + - name: expression1 + type: + - resolvesToNumber + - name: expression2 + type: + - resolvesToNumber tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/covarianceSamp/#example' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - covarianceSampForState: - $covarianceSamp: - - + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/covarianceSamp/#example + pipeline: + - $setWindowFields: + 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' - window: - documents: - - 'unbounded' - - 'current' + - $year: + date: $orderDate + - $quantity + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/denseRank.yaml b/generator/config/accumulator/denseRank.yaml index 0c50dd901..7b8fdd004 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 @@ -8,27 +8,23 @@ description: | Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. There are no gaps in the ranks. Ties receive the same rank. 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' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - quantity: -1 - output: - denseRankQuantityForState: - $denseRank: {} - - - 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' - sortBy: - orderDate: 1 - output: - denseRankOrderDateForState: - $denseRank: {} + - 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 + sortBy: + quantity: -1 + output: + denseRankQuantityForState: + $denseRank: {} + - 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 + sortBy: + orderDate: 1 + output: + denseRankOrderDateForState: + $denseRank: {} diff --git a/generator/config/accumulator/derivative.yaml b/generator/config/accumulator/derivative.yaml index 5745e9380..b7e427faf 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 @@ -8,40 +8,35 @@ description: | Returns the average rate of change within the specified window. New in MongoDB 5.0. arguments: - - - name: input - type: - - resolvesToNumber - - resolvesToDate - - - name: unit - type: - - timeUnit - optional: true - description: | - A string that specifies the time unit. Use one of these strings: "week", "day","hour", "minute", "second", "millisecond". - 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. + - name: input + type: + - resolvesToNumber + - resolvesToDate + - name: unit + type: + - timeUnit + optional: true + description: | + A string that specifies the time unit. Use one of these strings: "week", "day","hour", "minute", "second", "millisecond". + 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' - pipeline: - - - $setWindowFields: - partitionBy: '$truckID' - sortBy: - timeStamp: 1 - output: - truckAverageSpeed: - $derivative: - input: '$miles' - unit: 'hour' - window: - range: - - -30 - - 0 - unit: 'second' - - - $match: + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/derivative/#example + pipeline: + - $setWindowFields: + partitionBy: $truckID + sortBy: + timeStamp: 1 + output: truckAverageSpeed: - $gt: 50 + $derivative: + input: $miles + unit: hour + window: + range: + - -30 + - 0 + unit: second + - $match: + truckAverageSpeed: + $gt: 50 diff --git a/generator/config/accumulator/documentNumber.yaml b/generator/config/accumulator/documentNumber.yaml index b810ccd44..0bde9852f 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 @@ -8,15 +8,13 @@ description: | Returns the position of a document (known as the document number) in the $setWindowFields stage partition. Ties result in different adjacent document numbers. 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' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - quantity: -1 - output: - documentNumberForState: - $documentNumber: {} + - 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 + sortBy: + quantity: -1 + output: + documentNumberForState: + $documentNumber: {} diff --git a/generator/config/accumulator/expMovingAvg.yaml b/generator/config/accumulator/expMovingAvg.yaml index 3009dd115..4fd8d9005 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 @@ -8,53 +8,46 @@ description: | Returns the exponential moving average for the numeric expression. New in MongoDB 5.0. arguments: - - - name: input - type: - - resolvesToNumber - - - name: 'N' - type: - - int - optional: true - description: | - An integer that specifies the number of historical documents that have a significant mathematical weight in the exponential moving average calculation, with the most recent documents contributing the most weight. - You must specify either N or alpha. You cannot specify both. - The N value is used in this formula to calculate the current result based on the expression value from the current document being read and the previous result of the calculation: - - - name: alpha - type: - - double - optional: true - description: | - A double that specifies the exponential decay value to use in the exponential moving average calculation. A higher alpha value assigns a lower mathematical significance to previous results from the calculation. - You must specify either N or alpha. You cannot specify both. + - name: input + type: + - resolvesToNumber + - name: N + type: + - int + optional: true + description: | + An integer that specifies the number of historical documents that have a significant mathematical weight in the exponential moving average calculation, with the most recent documents contributing the most weight. + You must specify either N or alpha. You cannot specify both. + The N value is used in this formula to calculate the current result based on the expression value from the current document being read and the previous result of the calculation: + - name: alpha + type: + - double + optional: true + description: | + A double that specifies the exponential decay value to use in the exponential moving average calculation. A higher alpha value assigns a lower mathematical significance to previous results from the calculation. + 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' - pipeline: - - - $setWindowFields: - partitionBy: '$stock' - sortBy: - date: 1 - output: - expMovingAvgForStock: - $expMovingAvg: - input: '$price' - N: 2 - - - 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' - sortBy: - date: 1 - output: - expMovingAvgForStock: - $expMovingAvg: - input: '$price' - alpha: 0.75 + - 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 + sortBy: + date: 1 + output: + expMovingAvgForStock: + $expMovingAvg: + input: $price + N: 2 + - 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 + sortBy: + date: 1 + output: + expMovingAvgForStock: + $expMovingAvg: + input: $price + alpha: 0.75 diff --git a/generator/config/accumulator/first.yaml b/generator/config/accumulator/first.yaml index d82f831a0..daa1e6053 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 @@ -9,37 +9,31 @@ description: | Returns the result of an expression for the first document in a group or window. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/#use-in--group-stage' - pipeline: - - - $sort: - item: 1 - date: 1 - - - $group: - _id: '$item' - firstSale: - $first: '$date' - - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/#use-in--setwindowfields-stage' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - firstOrderTypeForState: - $first: '$type' - window: - documents: - - 'unbounded' - - 'current' + - name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/#use-in--group-stage + pipeline: + - $sort: + item: 1 + date: 1 + - $group: + _id: $item + firstSale: + $first: $date + - name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/#use-in--setwindowfields-stage + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + firstOrderTypeForState: + $first: $type + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/firstN.yaml b/generator/config/accumulator/firstN.yaml index cb7a6e96c..711fe5778 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 @@ -10,113 +10,92 @@ description: | The elements returned are meaningful only if in a specified sort order. If the group contains fewer than n elements, $firstN returns all elements in the group. arguments: - - - name: input - type: - - expression - description: | - An expression that resolves to the array from which to return n elements. - - - name: 'n' - type: - - resolvesToInt - description: | - A positive integral expression that is either a constant or depends on the _id value for $group. + - name: input + type: + - expression + description: | + An expression that resolves to the array from which to return n elements. + - name: n + type: + - resolvesToInt + description: | + 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' - pipeline: - - - $match: - gameId: 'G1' - - - $group: - _id: '$gameId' - firstThreeScores: - $firstN: - input: - - '$playerId' - - '$score' - n: 3 - - - 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' - playerId: - $firstN: - input: - - '$playerId' - - '$score' - n: 3 - - - 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' - playerId: - $firstN: - input: - - '$playerId' - - '$score' - n: 3 - - - 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' - gamescores: - $firstN: - input: '$score' - n: - $cond: - if: - $eq: - - '$gameId' - - 'G2' - then: 1 - else: 3 - + - 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 + pipeline: + - $match: + gameId: G1 + - $group: + _id: $gameId + firstThreeScores: + $firstN: + input: + - $playerId + - $score + n: 3 + - 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 + playerId: + $firstN: + input: + - $playerId + - $score + n: 3 + - 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 + playerId: + $firstN: + input: + - $playerId + - $score + n: 3 + - 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 + gamescores: + $firstN: + input: $score + n: + $cond: + if: + $eq: + - $gameId + - G2 + then: 1 + else: 3 diff --git a/generator/config/accumulator/integral.yaml b/generator/config/accumulator/integral.yaml index efc803597..dcfe55a07 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 @@ -8,36 +8,32 @@ description: | Returns the approximation of the area under a curve. New in MongoDB 5.0. arguments: - - - name: input - type: - - resolvesToNumber - - resolvesToDate - - - name: unit - type: - - timeUnit - optional: true - description: | - A string that specifies the time unit. Use one of these strings: "week", "day","hour", "minute", "second", "millisecond". - 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. + - name: input + type: + - resolvesToNumber + - resolvesToDate + - name: unit + type: + - timeUnit + optional: true + description: | + A string that specifies the time unit. Use one of these strings: "week", "day","hour", "minute", "second", "millisecond". + 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' - pipeline: - - - $setWindowFields: - partitionBy: '$powerMeterID' - sortBy: - timeStamp: 1 - output: - powerMeterKilowattHours: - $integral: - input: '$kilowatts' - unit: 'hour' - window: - range: - - 'unbounded' - - 'current' - unit: 'hour' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/integral/#example + pipeline: + - $setWindowFields: + partitionBy: $powerMeterID + sortBy: + timeStamp: 1 + output: + powerMeterKilowattHours: + $integral: + input: $kilowatts + unit: hour + window: + range: + - unbounded + - current + unit: hour diff --git a/generator/config/accumulator/last.yaml b/generator/config/accumulator/last.yaml index 969c05524..f4cfeca0b 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 @@ -9,37 +9,31 @@ description: | Returns the result of an expression for the last document in a group or window. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/' - pipeline: - - - $sort: - item: 1 - date: 1 - - - $group: - _id: '$item' - lastSalesDate: - $last: '$date' - - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/#use-in--setwindowfields-stage' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - lastOrderTypeForState: - $last: '$type' - window: - documents: - - 'current' - - 'unbounded' + - name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/ + pipeline: + - $sort: + item: 1 + date: 1 + - $group: + _id: $item + lastSalesDate: + $last: $date + - name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/#use-in--setwindowfields-stage + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + lastOrderTypeForState: + $last: $type + window: + documents: + - current + - unbounded diff --git a/generator/config/accumulator/lastN.yaml b/generator/config/accumulator/lastN.yaml index 13c9b72bd..befdaa844 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 @@ -10,80 +10,68 @@ description: | The elements returned are meaningful only if in a specified sort order. If the group contains fewer than n elements, $lastN returns all elements in the group. arguments: - - - name: input - type: - - resolvesToArray - description: | - An expression that resolves to the array from which to return n elements. - - - name: 'n' - type: - - resolvesToInt - description: | - An expression that resolves to a positive integer. The integer specifies the number of array elements that $firstN returns. + - name: input + type: + - resolvesToArray + description: | + An expression that resolves to the array from which to return n elements. + - name: n + type: + - resolvesToInt + description: | + 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' - pipeline: - - - $match: - gameId: 'G1' - - - $group: - _id: '$gameId' - lastThreeScores: - $lastN: - input: - - '$playerId' - - '$score' - n: 3 - - - 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' - playerId: - $lastN: - input: - - '$playerId' - - '$score' - n: 3 - - - 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' - playerId: - $lastN: - input: - - '$playerId' - - '$score' - n: 3 - - - 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' - gamescores: - $lastN: - input: '$score' - n: - $cond: - if: - $eq: - - '$gameId' - - 'G2' - then: 1 - else: 3 + - 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 + - $group: + _id: $gameId + lastThreeScores: + $lastN: + input: + - $playerId + - $score + n: 3 + - 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 + playerId: + $lastN: + input: + - $playerId + - $score + n: 3 + - 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 + playerId: + $lastN: + input: + - $playerId + - $score + n: 3 + - 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 + gamescores: + $lastN: + input: $score + n: + $cond: + if: + $eq: + - $gameId + - G2 + then: 1 + else: 3 diff --git a/generator/config/accumulator/linearFill.yaml b/generator/config/accumulator/linearFill.yaml index 034e6ab9e..b9b972ed7 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 @@ -9,32 +9,27 @@ description: | Available in the $setWindowFields stage. New in MongoDB 5.3. arguments: - - - name: expression - type: - - resolvesToNumber + - name: expression + type: + - 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' - pipeline: - - - $setWindowFields: - sortBy: - time: 1 - output: - price: - $linearFill: '$price' - - - 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: - sortBy: - time: 1 - output: - linearFillPrice: - $linearFill: '$price' - locfPrice: - $locf: '$price' + - 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: + sortBy: + time: 1 + output: + price: + $linearFill: $price + - 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: + sortBy: + time: 1 + output: + linearFillPrice: + $linearFill: $price + locfPrice: + $locf: $price diff --git a/generator/config/accumulator/locf.yaml b/generator/config/accumulator/locf.yaml index 63979bca4..3bb20c821 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 @@ -9,19 +9,16 @@ description: | Available in the $setWindowFields stage. New in MongoDB 5.2. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - 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' - pipeline: - - - $setWindowFields: - sortBy: - time: 1 - output: - price: - $locf: '$price' + - 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: + sortBy: + time: 1 + output: + price: + $locf: $price diff --git a/generator/config/accumulator/max.yaml b/generator/config/accumulator/max.yaml index 165cefc43..ce07e72de 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 @@ -9,38 +9,33 @@ description: | Returns the maximum value that results from applying an expression to each document. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#use-in--group-stage' - pipeline: - - - $group: - _id: '$item' - maxTotalAmount: - $max: - $multiply: - - '$price' - - '$quantity' - maxQuantity: - $max: '$quantity' - - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#use-in--setwindowfields-stage' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - maximumQuantityForState: - $max: '$quantity' - window: - documents: - - 'unbounded' - - 'current' + - name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#use-in--group-stage + pipeline: + - $group: + _id: $item + maxTotalAmount: + $max: + $multiply: + - $price + - $quantity + maxQuantity: + $max: $quantity + - name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#use-in--setwindowfields-stage + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + maximumQuantityForState: + $max: $quantity + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/maxN.yaml b/generator/config/accumulator/maxN.yaml index 4014782a8..c1d7f7c82 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 @@ -8,66 +8,57 @@ encode: object description: | Returns the n largest values in an array. Distinct from the $maxN accumulator. arguments: - - - name: input - type: - - resolvesToArray - description: | - An expression that resolves to the array from which to return the maximal n elements. - - - name: 'n' - type: - - resolvesToInt - description: | - An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. + - name: input + type: + - resolvesToArray + description: | + An expression that resolves to the array from which to return the maximal n elements. + - name: n + type: + - resolvesToInt + description: | + 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' - pipeline: - - - $match: - gameId: 'G1' - - - $group: - _id: '$gameId' - maxThreeScores: - $maxN: - input: - - '$score' - - '$playerId' - n: 3 - - - 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' - maxScores: - $maxN: - input: - - '$score' - - '$playerId' - n: 3 - - - 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' - gamescores: - $maxN: - input: - - '$score' - - '$playerId' - n: - $cond: - if: - $eq: - - '$gameId' - - 'G2' - then: 1 - else: 3 + - 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 + - $group: + _id: $gameId + maxThreeScores: + $maxN: + input: + - $score + - $playerId + n: 3 + - 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 + maxScores: + $maxN: + input: + - $score + - $playerId + n: 3 + - 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 + gamescores: + $maxN: + input: + - $score + - $playerId + n: + $cond: + if: + $eq: + - $gameId + - G2 + then: 1 + else: 3 diff --git a/generator/config/accumulator/median.yaml b/generator/config/accumulator/median.yaml index e743c6982..1e7a459e6 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 @@ -13,49 +13,42 @@ description: | $setWindowFields It is also available as an aggregation expression. arguments: - - - name: input - type: - - resolvesToNumber - 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. - - - name: method - type: - - accumulatorPercentile - description: | - The method that mongod uses to calculate the 50th percentile value. The method must be 'approximate'. + - name: input + type: + - resolvesToNumber + 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. + - name: method + type: + - accumulatorPercentile + description: | + 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' - pipeline: - - - $group: - _id: ~ + - 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: ~ + test01_median: + $median: + input: $test01 + method: approximate + - 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: + sortBy: + test01: 1 + output: test01_median: $median: - input: '$test01' - method: 'approximate' - - - 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: - sortBy: - test01: 1 - output: - test01_median: - $median: - input: '$test01' - method: 'approximate' - window: - range: - - -3 - - 3 - - - $project: - _id: 0 - studentId: 1 - test01_median: 1 + input: $test01 + method: approximate + window: + range: + - -3 + - 3 + - $project: + _id: 0 + studentId: 1 + test01_median: 1 diff --git a/generator/config/accumulator/mergeObjects.yaml b/generator/config/accumulator/mergeObjects.yaml index d68728001..2b994f16e 100644 --- a/generator/config/accumulator/mergeObjects.yaml +++ b/generator/config/accumulator/mergeObjects.yaml @@ -1,25 +1,22 @@ # $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 description: | Combines multiple documents into a single document. arguments: - - - name: document - type: - - resolvesToObject - description: | - Any valid expression that resolves to a document. + - name: document + type: + - resolvesToObject + description: | + 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' - pipeline: - - - $group: - _id: '$item' - mergedSales: - $mergeObjects: '$quantity' + - name: $mergeObjects as an Accumulator + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/#-mergeobjects-as-an-accumulator + pipeline: + - $group: + _id: $item + mergedSales: + $mergeObjects: $quantity diff --git a/generator/config/accumulator/min.yaml b/generator/config/accumulator/min.yaml index 226d56ec8..437607303 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 @@ -9,33 +9,28 @@ description: | Returns the minimum value that results from applying an expression to each document. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#use-in--group-stage' - pipeline: - - - $group: - _id: '$item' - minQuantity: - $min: '$quantity' - - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#use-in--setwindowfields-stage' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - minimumQuantityForState: - $min: '$quantity' - window: - documents: - - 'unbounded' - - 'current' + - name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#use-in--group-stage + pipeline: + - $group: + _id: $item + minQuantity: + $min: $quantity + - name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#use-in--setwindowfields-stage + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + minimumQuantityForState: + $min: $quantity + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/minN.yaml b/generator/config/accumulator/minN.yaml index 24719a22a..58b3286bf 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 @@ -8,66 +8,57 @@ encode: object description: | Returns the n smallest values in an array. Distinct from the $minN accumulator. arguments: - - - name: input - type: - - resolvesToArray - description: | - An expression that resolves to the array from which to return the maximal n elements. - - - name: 'n' - type: - - resolvesToInt - description: | - An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. + - name: input + type: + - resolvesToArray + description: | + An expression that resolves to the array from which to return the maximal n elements. + - name: n + type: + - resolvesToInt + description: | + 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' - pipeline: - - - $match: - gameId: 'G1' - - - $group: - _id: '$gameId' - minScores: - $minN: - input: - - '$score' - - '$playerId' - n: 3 - - - 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' - minScores: - $minN: - input: - - '$score' - - '$playerId' - n: 3 - - - 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' - gamescores: - $minN: - input: - - '$score' - - '$playerId' - n: - $cond: - if: - $eq: - - '$gameId' - - 'G2' - then: 1 - else: 3 + - 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 + - $group: + _id: $gameId + minScores: + $minN: + input: + - $score + - $playerId + n: 3 + - 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 + minScores: + $minN: + input: + - $score + - $playerId + n: 3 + - 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 + gamescores: + $minN: + input: + - $score + - $playerId + n: + $cond: + if: + $eq: + - $gameId + - G2 + then: 1 + else: 3 diff --git a/generator/config/accumulator/percentile.yaml b/generator/config/accumulator/percentile.yaml index b3c41b0e4..0cca80c08 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 @@ -8,95 +8,98 @@ encode: object description: | Returns an array of scalar values that correspond to specified percentile values. New in MongoDB 7.0. - This operator is available as an accumulator in these stages: $group - $setWindowFields - It is also available as an aggregation expression. arguments: - - - name: input - type: - - resolvesToNumber - 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 - 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. - - - name: method - type: - - accumulatorPercentile - description: | - The method that mongod uses to calculate the percentile value. The method must be 'approximate'. + - name: input + type: + - resolvesToNumber + 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 + 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. + - name: method + type: + - accumulatorPercentile + description: | + 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' - pipeline: - - - $group: - _id: ~ - test01_percentiles: + - 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: ~ + test01_percentiles: + $percentile: + input: $test01 + p: + - 0.95 + method: approximate + - 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: ~ + test01_percentiles: + $percentile: + 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 + test03_percentiles: + $percentile: + 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 + - 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: + sortBy: + test01: 1 + output: + test01_95percentile: $percentile: - input: '$test01' + input: $test01 p: - 0.95 - method: 'approximate' - - - 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: ~ - test01_percentiles: - $percentile: - 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' - test03_percentiles: - $percentile: - 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' - - - 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: - sortBy: - test01: 1 - output: - test01_95percentile: - $percentile: - input: '$test01' - p: - - 0.95 - method: 'approximate' - window: - range: - - -3 - - 3 - - - $project: - _id: 0 - studentId: 1 - test01_95percentile: 1 + method: approximate + window: + range: + - -3 + - 3 + - $project: + _id: 0 + studentId: 1 + test01_95percentile: 1 diff --git a/generator/config/accumulator/push.yaml b/generator/config/accumulator/push.yaml index 3fc367c59..f18856f8e 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 @@ -9,47 +9,43 @@ description: | Returns an array of values that result from applying an expression to each document. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/#use-in--group-stage' - pipeline: - - - $sort: - date: 1 - item: 1 - - - $group: - _id: - day: + - name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/#use-in--group-stage + pipeline: + - $sort: + date: 1 + item: 1 + - $group: + _id: + day: # Example uses the short form, the builder always generates the verbose form # $dayOfYear: '$date' - $dayOfYear: - date: '$date' - year: + $dayOfYear: + date: $date + year: # Example uses the short form, the builder always generates the verbose form # $year: '$date' - $year: - date: '$date' - itemsSold: - $push: - item: '$item' - quantity: '$quantity' - - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/#use-in--setwindowfields-stage' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - quantitiesForState: - $push: '$quantity' - window: - documents: ['unbounded', 'current'] + $year: + date: $date + itemsSold: + $push: + item: $item + quantity: $quantity + - name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/#use-in--setwindowfields-stage + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + quantitiesForState: + $push: $quantity + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/rank.yaml b/generator/config/accumulator/rank.yaml index 8b8fd041b..c426d9a58 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 @@ -8,27 +8,23 @@ description: | Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. 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' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - quantity: -1 - output: - rankQuantityForState: - $rank: {} - - - 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' - sortBy: - orderDate: 1 - output: - rankOrderDateForState: - $rank: {} + - 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 + sortBy: + quantity: -1 + output: + rankQuantityForState: + $rank: {} + - 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 + sortBy: + orderDate: 1 + output: + rankOrderDateForState: + $rank: {} diff --git a/generator/config/accumulator/shift.yaml b/generator/config/accumulator/shift.yaml index f4984f056..e0f033b59 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 @@ -8,58 +8,51 @@ description: | Returns the value from an expression applied to a document in a specified position relative to the current document in the $setWindowFields stage partition. New in MongoDB 5.0. arguments: - - - name: output - type: - - expression - description: | - Specifies an expression to evaluate and return in the output. - - - name: by - type: - - int - description: | - Specifies an integer with a numeric document position relative to the current document in the output. - For example: - 1 specifies the document position after the current document. - -1 specifies the document position before the current document. - -2 specifies the document position that is two positions before the current document. - - - name: default - type: - - expression - description: | - Specifies an optional default expression to evaluate if the document position is outside of the implicit $setWindowFields stage window. The implicit window contains all the documents in the partition. - The default expression must evaluate to a constant value. - If you do not specify a default expression, $shift returns null for documents whose positions are outside of the implicit $setWindowFields stage window. + - name: output + type: + - expression + description: | + Specifies an expression to evaluate and return in the output. + - name: by + type: + - int + description: | + Specifies an integer with a numeric document position relative to the current document in the output. + For example: + 1 specifies the document position after the current document. + -1 specifies the document position before the current document. + -2 specifies the document position that is two positions before the current document. + - name: default + type: + - expression + description: | + Specifies an optional default expression to evaluate if the document position is outside of the implicit $setWindowFields stage window. The implicit window contains all the documents in the partition. + The default expression must evaluate to a constant value. + 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' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - quantity: -1 - output: - shiftQuantityForState: - $shift: - output: '$quantity' - by: 1 - default: 'Not available' - - - 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' - sortBy: - quantity: -1 - output: - shiftQuantityForState: - $shift: - output: '$quantity' - by: -1 - default: 'Not available' + - 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 + sortBy: + quantity: -1 + output: + shiftQuantityForState: + $shift: + output: $quantity + by: 1 + default: Not available + - 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 + sortBy: + quantity: -1 + output: + shiftQuantityForState: + $shift: + output: $quantity + by: -1 + default: Not available diff --git a/generator/config/accumulator/stdDevPop.yaml b/generator/config/accumulator/stdDevPop.yaml index 8916456d4..2ba781a15 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 @@ -10,31 +10,28 @@ description: | If the values represent only a sample of a population of data from which to generalize about the population, use $stdDevSamp instead. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - resolvesToNumber + - name: expression + type: + - resolvesToNumber tests: - - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#use-in--group-stage' - pipeline: - - - $group: - _id: '$quiz' - stdDev: - $stdDevPop: '$score' - - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#use-in--setwindowfields-stage' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - stdDevPopQuantityForState: - $stdDevPop: '$quantity' - window: - documents: ['unbounded', 'current'] + - name: Use in $group Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#use-in--group-stage + pipeline: + - $group: + _id: $quiz + stdDev: + $stdDevPop: $score + - name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#use-in--setwindowfields-stage + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + stdDevPopQuantityForState: + $stdDevPop: $quantity + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/stdDevSamp.yaml b/generator/config/accumulator/stdDevSamp.yaml index 94ac33d15..6ee7a4e3e 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 @@ -10,34 +10,30 @@ description: | If the values represent the entire population of data or you do not wish to generalize about a larger population, use $stdDevPop instead. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - resolvesToNumber + - name: expression + type: + - resolvesToNumber tests: - - - 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: ~ - ageStdDev: - $stdDevSamp: '$age' - - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/#use-in--setwindowfields-stage' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - stdDevSampQuantityForState: - $stdDevSamp: '$quantity' - window: - documents: ['unbounded', 'current'] + - 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: ~ + ageStdDev: + $stdDevSamp: $age + - name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/#use-in--setwindowfields-stage + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + stdDevSampQuantityForState: + $stdDevSamp: $quantity + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/sum.yaml b/generator/config/accumulator/sum.yaml index c40417ef4..d0e339899 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 @@ -9,48 +9,43 @@ description: | Returns a sum of numerical values. Ignores non-numeric values. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - resolvesToNumber + - name: expression + type: + - resolvesToNumber tests: - - - name: 'Use in $group Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/#use-in--group-stage' - pipeline: - - - $group: - _id: - day: + - 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' - year: + $dayOfYear: + date: $date + year: # Example uses the short form, the builder always generates the verbose form # $year: '$date' - $year: - date: '$date' - totalAmount: - $sum: - $multiply: - - '$price' - - '$quantity' - count: - $sum: 1 - - - name: 'Use in $setWindowFields Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/#use-in--setwindowfields-stage' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - sumQuantityForState: - $sum: '$quantity' - window: - documents: - - 'unbounded' - - 'current' + $year: + date: $date + totalAmount: + $sum: + $multiply: + - $price + - $quantity + count: + $sum: 1 + - name: Use in $setWindowFields Stage + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/#use-in--setwindowfields-stage + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + sumQuantityForState: + $sum: $quantity + window: + documents: + - unbounded + - current diff --git a/generator/config/accumulator/top.yaml b/generator/config/accumulator/top.yaml index 94923cccd..19de8e0ab 100644 --- a/generator/config/accumulator/top.yaml +++ b/generator/config/accumulator/top.yaml @@ -1,56 +1,48 @@ # $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 description: | Returns the top element within a group according to the specified sort order. New in MongoDB 5.2. - Available in the $group and $setWindowFields stages. arguments: - - - name: sortBy - type: - - sortBy - description: | - Specifies the order of results, with syntax similar to $sort. - - - name: output - type: - - expression - description: | - Represents the output for each element in the group and can be any expression. + - name: sortBy + type: + - sortBy + description: | + Specifies the order of results, with syntax similar to $sort. + - name: output + type: + - expression + description: | + 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' - pipeline: - - - $match: - gameId: 'G1' - - - $group: - _id: '$gameId' - playerId: - $top: - output: - - '$playerId' - - '$score' - sortBy: - score: -1 - - - 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' - playerId: - $top: - output: - - '$playerId' - - '$score' - sortBy: - score: -1 + - name: Find the Top Score + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/top/#find-the-top-score + pipeline: + - $match: + gameId: G1 + - $group: + _id: $gameId + playerId: + $top: + output: + - $playerId + - $score + sortBy: + score: -1 + - 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 + playerId: + $top: + output: + - $playerId + - $score + sortBy: + score: -1 diff --git a/generator/config/accumulator/topN.yaml b/generator/config/accumulator/topN.yaml index c5eff6056..255362db8 100644 --- a/generator/config/accumulator/topN.yaml +++ b/generator/config/accumulator/topN.yaml @@ -1,85 +1,74 @@ # $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 description: | Returns an aggregation of the top n fields within a group, according to the specified sort order. New in MongoDB 5.2. - Available in the $group and $setWindowFields stages. arguments: - - - name: 'n' - type: - - resolvesToInt - description: | - limits the number of results per group and has to be a positive integral expression that is either a constant or depends on the _id value for $group. - - - name: sortBy - type: - - sortBy - description: | - Specifies the order of results, with syntax similar to $sort. - - - name: output - type: - - expression - description: | - Represents the output for each element in the group and can be any expression. + - name: n + type: + - resolvesToInt + description: | + limits the number of results per group and has to be a positive integral expression that is either a constant or depends on the _id value for $group. + - name: sortBy + type: + - sortBy + description: | + Specifies the order of results, with syntax similar to $sort. + - name: output + type: + - expression + description: | + 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' - pipeline: - - - $match: - gameId: 'G1' - - - $group: - _id: '$gameId' - playerId: - $topN: - output: - - '$playerId' - - '$score' - sortBy: - score: -1 - n: 3 - - - 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' - playerId: - $topN: - output: - - '$playerId' - - '$score' - sortBy: - score: -1 - n: 3 - - - 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' - gamescores: - $topN: - output: '$score' - n: - $cond: - if: - $eq: - - '$gameId' - - 'G2' - then: 1 - else: 3 - sortBy: - score: -1 + - 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 + - $group: + _id: $gameId + playerId: + $topN: + output: + - $playerId + - $score + sortBy: + score: -1 + n: 3 + - 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 + playerId: + $topN: + output: + - $playerId + - $score + sortBy: + score: -1 + n: 3 + - 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 + gamescores: + $topN: + output: $score + n: + $cond: + if: + $eq: + - $gameId + - G2 + then: 1 + else: 3 + sortBy: + score: -1 diff --git a/generator/config/expression/abs.yaml b/generator/config/expression/abs.yaml index fe29e44e3..657769bb8 100644 --- a/generator/config/expression/abs.yaml +++ b/generator/config/expression/abs.yaml @@ -1,25 +1,22 @@ # $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 description: | Returns the absolute value of a number. arguments: - - - name: value - type: - - resolvesToNumber + - name: value + type: + - resolvesToNumber tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/#example' - pipeline: - - - $project: - delta: - $abs: - $subtract: - - '$startTemp' - - '$endTemp' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/#example + pipeline: + - $project: + delta: + $abs: + $subtract: + - $startTemp + - $endTemp diff --git a/generator/config/expression/acos.yaml b/generator/config/expression/acos.yaml index 7deca736d..1f80bfa50 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 @@ -8,24 +8,21 @@ encode: single description: | Returns the inverse cosine (arc cosine) of a value in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $acos takes any valid expression that resolves to a number between -1 and 1, e.g. -1 <= value <= 1. - $acos returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $acos takes any valid expression that resolves to a number between -1 and 1, e.g. -1 <= value <= 1. + $acos returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. + 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' - pipeline: - - - $addFields: - angle_a: - $radiansToDegrees: - $acos: - $divide: - - '$side_b' - - '$hypotenuse' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/acos/#example + pipeline: + - $addFields: + angle_a: + $radiansToDegrees: + $acos: + $divide: + - $side_b + - $hypotenuse diff --git a/generator/config/expression/acosh.yaml b/generator/config/expression/acosh.yaml index ce575e317..cfa764338 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 @@ -8,21 +8,18 @@ encode: single description: | Returns the inverse hyperbolic cosine (hyperbolic arc cosine) of a value in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $acosh takes any valid expression that resolves to a number between 1 and +Infinity, e.g. 1 <= value <= +Infinity. - $acosh returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $acosh takes any valid expression that resolves to a number between 1 and +Infinity, e.g. 1 <= value <= +Infinity. + $acosh returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. + 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' - pipeline: - - - $addFields: - y-coordinate: - $radiansToDegrees: - $acosh: '$x-coordinate' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/acosh/#example + pipeline: + - $addFields: + y-coordinate: + $radiansToDegrees: + $acosh: $x-coordinate diff --git a/generator/config/expression/add.yaml b/generator/config/expression/add.yaml index fa23253d0..047be409d 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 @@ -11,34 +11,29 @@ encode: single description: | Adds numbers to return the sum, or adds numbers and a date to return a new date. If adding numbers and a date, treats the numbers as milliseconds. Accepts any number of argument expressions, but at most, one expression can resolve to a date. arguments: - - - name: expression - type: - - resolvesToNumber - - resolvesToDate - variadic: array - description: | - The arguments can be any valid expression as long as they resolve to either all numbers or to numbers and a date. + - name: expression + type: + - resolvesToNumber + - resolvesToDate + variadic: array + description: | + 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' - pipeline: - - - $project: - item: 1 - total: - $add: - - '$price' - - '$fee' - - - 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' - - 259200000 + - name: Add Numbers + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/#add-numbers + pipeline: + - $project: + item: 1 + total: + $add: + - $price + - $fee + - 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 + - 259200000 diff --git a/generator/config/expression/allElementsTrue.yaml b/generator/config/expression/allElementsTrue.yaml index 7301f8d68..13b4cc4a0 100644 --- a/generator/config/expression/allElementsTrue.yaml +++ b/generator/config/expression/allElementsTrue.yaml @@ -1,25 +1,22 @@ # $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 description: | Returns true if no element of a set evaluates to false, otherwise, returns false. Accepts a single argument expression. arguments: - - - name: expression - type: - - resolvesToArray + - name: expression + type: + - resolvesToArray tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/allElementsTrue/#example' - pipeline: - - - $project: - responses: 1 - isAllTrue: - $allElementsTrue: - - '$responses' - _id: 0 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/allElementsTrue/#example + pipeline: + - $project: + responses: 1 + isAllTrue: + $allElementsTrue: + - $responses + _id: 0 diff --git a/generator/config/expression/and.yaml b/generator/config/expression/and.yaml index 96057d249..94b1b32bf 100644 --- a/generator/config/expression/and.yaml +++ b/generator/config/expression/and.yaml @@ -1,37 +1,32 @@ # $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 description: | Returns true only when all its expressions evaluate to true. Accepts any number of argument expressions. arguments: - - - name: expression - type: - - expression - - resolvesToBool - - resolvesToNumber - - resolvesToString - - resolvesToNull - variadic: array + - name: expression + type: + - expression + - resolvesToBool + - resolvesToNumber + - resolvesToString + - resolvesToNull + variadic: array tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/#example' - pipeline: - - - $project: - item: 1 - qty: 1 - result: - $and: - - - $gt: - - '$qty' - - 100 - - - $lt: - - '$qty' - - 250 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/#example + pipeline: + - $project: + item: 1 + qty: 1 + result: + $and: + - $gt: + - $qty + - 100 + - $lt: + - $qty + - 250 diff --git a/generator/config/expression/anyElementTrue.yaml b/generator/config/expression/anyElementTrue.yaml index 50fe665b6..545a39c95 100644 --- a/generator/config/expression/anyElementTrue.yaml +++ b/generator/config/expression/anyElementTrue.yaml @@ -1,25 +1,22 @@ # $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 description: | Returns true if any elements of a set evaluate to true; otherwise, returns false. Accepts a single argument expression. arguments: - - - name: expression - type: - - resolvesToArray + - name: expression + type: + - resolvesToArray tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/anyElementTrue/#example' - pipeline: - - - $project: - responses: 1 - isAnyTrue: - $anyElementTrue: - - '$responses' - _id: 0 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/anyElementTrue/#example + pipeline: + - $project: + responses: 1 + isAnyTrue: + $anyElementTrue: + - $responses + _id: 0 diff --git a/generator/config/expression/arrayElemAt.yaml b/generator/config/expression/arrayElemAt.yaml index 09fe9dae1..13b65c73c 100644 --- a/generator/config/expression/arrayElemAt.yaml +++ b/generator/config/expression/arrayElemAt.yaml @@ -1,33 +1,29 @@ # $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 description: | Returns the element at the specified array index. arguments: - - - name: array - type: - - resolvesToArray - - - name: idx - type: - - resolvesToInt + - name: array + type: + - resolvesToArray + - name: idx + type: + - resolvesToInt tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/#example' - pipeline: - - - $project: - name: 1 - first: - $arrayElemAt: - - '$favorites' - - 0 - last: - $arrayElemAt: - - '$favorites' - - -1 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/#example + pipeline: + - $project: + name: 1 + first: + $arrayElemAt: + - $favorites + - 0 + last: + $arrayElemAt: + - $favorites + - -1 diff --git a/generator/config/expression/arrayToObject.yaml b/generator/config/expression/arrayToObject.yaml index 87026f7a7..95b2fa7df 100644 --- a/generator/config/expression/arrayToObject.yaml +++ b/generator/config/expression/arrayToObject.yaml @@ -1,50 +1,41 @@ # $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 description: | Converts an array of key value pairs to a document. arguments: - - - name: array - type: - - resolvesToArray + - name: array + type: + - resolvesToArray tests: - - - name: '$arrayToObject Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/#-arraytoobject--example' - pipeline: - - - $project: - item: 1 - dimensions: + - 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' - - - name: '$objectToArray and $arrayToObject Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/#-objecttoarray----arraytoobject-example' - pipeline: - - - $addFields: - instock: - $objectToArray: '$instock' - - - $addFields: - instock: - $concatArrays: - - '$instock' - - - - - k: 'total' - v: - $sum: - - '$instock.v' - - - $addFields: - instock: - $arrayToObject: - - '$instock' + $arrayToObject: + - $dimensions + - name: $objectToArray and $arrayToObject Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/#-objecttoarray----arraytoobject-example + pipeline: + - $addFields: + instock: + $objectToArray: $instock + - $addFields: + instock: + $concatArrays: + - $instock + - - k: total + v: + $sum: + - $instock.v + - $addFields: + instock: + $arrayToObject: + - $instock diff --git a/generator/config/expression/asin.yaml b/generator/config/expression/asin.yaml index 43e2832a2..0ea55e84f 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 @@ -8,24 +8,21 @@ encode: single description: | Returns the inverse sin (arc sine) of a value in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $asin takes any valid expression that resolves to a number between -1 and 1, e.g. -1 <= value <= 1. - $asin returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $asin takes any valid expression that resolves to a number between -1 and 1, e.g. -1 <= value <= 1. + $asin returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. + 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' - pipeline: - - - $addFields: - angle_a: - $radiansToDegrees: - $asin: - $divide: - - '$side_a' - - '$hypotenuse' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/asin/#example + pipeline: + - $addFields: + angle_a: + $radiansToDegrees: + $asin: + $divide: + - $side_a + - $hypotenuse diff --git a/generator/config/expression/asinh.yaml b/generator/config/expression/asinh.yaml index 6d45c14fa..89a984399 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 @@ -8,21 +8,18 @@ encode: single description: | Returns the inverse hyperbolic sine (hyperbolic arc sine) of a value in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $asinh takes any valid expression that resolves to a number. - $asinh returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $asinh takes any valid expression that resolves to a number. + $asinh returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. + 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' - pipeline: - - - $addFields: - y-coordinate: - $radiansToDegrees: - $asinh: '$x-coordinate' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/asinh/#example + pipeline: + - $addFields: + y-coordinate: + $radiansToDegrees: + $asinh: $x-coordinate diff --git a/generator/config/expression/atan.yaml b/generator/config/expression/atan.yaml index a8bb1674f..4126ec805 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 @@ -8,24 +8,21 @@ encode: single description: | Returns the inverse tangent (arc tangent) of a value in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $atan takes any valid expression that resolves to a number. - $atan returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $atan takes any valid expression that resolves to a number. + $atan returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. + 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' - pipeline: - - - $addFields: - angle_a: - $radiansToDegrees: - $atan: - $divide: - - '$side_b' - - '$side_a' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan/#example + pipeline: + - $addFields: + angle_a: + $radiansToDegrees: + $atan: + $divide: + - $side_b + - $side_a diff --git a/generator/config/expression/atan2.yaml b/generator/config/expression/atan2.yaml index 1abc55e6a..38e7f6615 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 @@ -8,27 +8,23 @@ encode: array description: | Returns the inverse tangent (arc tangent) of y / x in radians, where y and x are the first and second values passed to the expression respectively. arguments: - - - name: 'y' - type: - - resolvesToNumber - description: | - $atan2 takes any valid expression that resolves to a number. - $atan2 returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. - By default $atan returns values as a double. $atan2 can also return values as a 128-bit decimal as long as the expression resolves to a 128-bit decimal value. - - - name: x - type: - - resolvesToNumber + - name: y + type: + - resolvesToNumber + description: | + $atan2 takes any valid expression that resolves to a number. + $atan2 returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. + By default $atan returns values as a double. $atan2 can also return values as a 128-bit decimal as long as the expression resolves to a 128-bit decimal value. + - name: x + type: + - resolvesToNumber tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/#example' - pipeline: - - - $addFields: - angle_a: - $radiansToDegrees: - $atan2: - - '$side_b' - - '$side_a' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/#example + pipeline: + - $addFields: + angle_a: + $radiansToDegrees: + $atan2: + - $side_b + - $side_a diff --git a/generator/config/expression/atanh.yaml b/generator/config/expression/atanh.yaml index 501fba2bf..5d83baaa6 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 @@ -8,21 +8,18 @@ encode: single description: | Returns the inverse hyperbolic tangent (hyperbolic arc tangent) of a value in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $atanh takes any valid expression that resolves to a number between -1 and 1, e.g. -1 <= value <= 1. - $atanh returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $atanh takes any valid expression that resolves to a number between -1 and 1, e.g. -1 <= value <= 1. + $atanh returns values in radians. Use $radiansToDegrees operator to convert the output value from radians to degrees. + 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' - pipeline: - - - $addFields: - y-coordinate: - $radiansToDegrees: - $atanh: '$x-coordinate' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/atanh/#example + pipeline: + - $addFields: + y-coordinate: + $radiansToDegrees: + $atanh: $x-coordinate diff --git a/generator/config/expression/avg.yaml b/generator/config/expression/avg.yaml index 3bb771936..6f8292171 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 @@ -8,28 +8,25 @@ description: | Returns an average of numerical values. Ignores non-numeric values. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - resolvesToNumber - variadic: array + - name: expression + type: + - resolvesToNumber + variadic: array tests: - - - name: 'Use in $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--project-stage' - pipeline: - - - $project: - quizAvg: + - 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' - labAvg: + $avg: + - $quizzes + labAvg: # $avg: '$labs' - $avg: - - '$labs' - examAvg: - $avg: - - '$final' - - '$midterm' + $avg: + - $labs + examAvg: + $avg: + - $final + - $midterm diff --git a/generator/config/expression/binarySize.yaml b/generator/config/expression/binarySize.yaml index eb0146f8c..4acb7b24d 100644 --- a/generator/config/expression/binarySize.yaml +++ b/generator/config/expression/binarySize.yaml @@ -1,25 +1,22 @@ # $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 description: | Returns the size of a given string or binary data value's content in bytes. arguments: - - - name: expression - type: - - resolvesToString - - resolvesToBinData - - resolvesToNull + - name: expression + type: + - resolvesToString + - resolvesToBinData + - resolvesToNull tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/#example' - pipeline: - - - $project: - name: '$name' - imageSize: - $binarySize: '$binary' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/#example + pipeline: + - $project: + name: $name + imageSize: + $binarySize: $binary diff --git a/generator/config/expression/bitAnd.yaml b/generator/config/expression/bitAnd.yaml index 271cc0973..64efdc8c6 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 @@ -9,30 +9,25 @@ description: | Returns the result of a bitwise and operation on an array of int or long values. New in MongoDB 6.3. arguments: - - - name: expression - type: - - resolvesToInt - - resolvesToLong - variadic: array + - name: expression + type: + - resolvesToInt + - resolvesToLong + 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' - pipeline: - - - $project: - result: - $bitAnd: - - '$a' - - '$b' - - - 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" } + - 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 + - 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'} diff --git a/generator/config/expression/bitNot.yaml b/generator/config/expression/bitNot.yaml index 5211fa42a..d43b7b013 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 @@ -9,17 +9,14 @@ description: | Returns the result of a bitwise not operation on a single argument or an array that contains a single int or long value. New in MongoDB 6.3. arguments: - - - name: expression - type: - - resolvesToInt - - resolvesToLong + - name: expression + type: + - resolvesToInt + - resolvesToLong tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitNot/#example' - pipeline: - - - $project: - result: - $bitNot: '$a' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitNot/#example + pipeline: + - $project: + result: + $bitNot: $a diff --git a/generator/config/expression/bitOr.yaml b/generator/config/expression/bitOr.yaml index 084ac224c..e6e70e74d 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 @@ -9,30 +9,25 @@ description: | Returns the result of a bitwise or operation on an array of int or long values. New in MongoDB 6.3. arguments: - - - name: expression - type: - - resolvesToInt - - resolvesToLong - variadic: array + - name: expression + type: + - resolvesToInt + - resolvesToLong + 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' - pipeline: - - - $project: - result: - $bitOr: - - '$a' - - '$b' - - - 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" } + - 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 + - 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'} diff --git a/generator/config/expression/bitXor.yaml b/generator/config/expression/bitXor.yaml index f4acc4df4..2669607fb 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 @@ -9,20 +9,17 @@ description: | Returns the result of a bitwise xor (exclusive or) operation on an array of int and long values. New in MongoDB 6.3. arguments: - - - name: expression - type: - - resolvesToInt - - resolvesToLong - variadic: array + - name: expression + type: + - resolvesToInt + - resolvesToLong + variadic: array tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitXor/#example' - pipeline: - - - $project: - result: - $bitXor: - - '$a' - - '$b' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitXor/#example + pipeline: + - $project: + result: + $bitXor: + - $a + - $b diff --git a/generator/config/expression/bsonSize.yaml b/generator/config/expression/bsonSize.yaml index 712188c52..2a3617ec4 100644 --- a/generator/config/expression/bsonSize.yaml +++ b/generator/config/expression/bsonSize.yaml @@ -1,48 +1,39 @@ # $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 description: | Returns the size in bytes of a given document (i.e. BSON type Object) when encoded as BSON. arguments: - - - name: object - type: - - resolvesToObject - - resolvesToNull + - name: object + type: + - resolvesToObject + - resolvesToNull tests: - - - 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' - - - 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: ~ - combined_object_size: - $sum: - $bsonSize: '$$ROOT' - - - 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' - task_object_size: - $bsonSize: '$current_task' - - - $sort: - task_object_size: -1 - - - $limit: 1 + - 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 + - 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: ~ + combined_object_size: + $sum: + $bsonSize: $$ROOT + - 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 + task_object_size: + $bsonSize: $current_task + - $sort: + task_object_size: -1 + - $limit: 1 diff --git a/generator/config/expression/case.yaml b/generator/config/expression/case.yaml index ccf463c90..c2df052cc 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 @@ -8,15 +8,13 @@ wrapObject: false description: | Represents a single case in a $switch expression arguments: - - - name: case - type: - - resolvesToBool - description: | - 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. - - - name: then - type: - - expression - description: | - Can be any valid expression. + - name: case + type: + - resolvesToBool + description: | + 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. + - name: then + type: + - expression + description: |- + Can be any valid expression. diff --git a/generator/config/expression/ceil.yaml b/generator/config/expression/ceil.yaml index 73c31ddb7..31a060d52 100644 --- a/generator/config/expression/ceil.yaml +++ b/generator/config/expression/ceil.yaml @@ -1,25 +1,22 @@ # $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 description: | Returns the smallest integer greater than or equal to the specified number. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - 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. + - name: expression + type: + - resolvesToNumber + description: | + 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' - pipeline: - - - $project: - value: 1 - ceilingValue: - $ceil: '$value' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/#example + pipeline: + - $project: + value: 1 + ceilingValue: + $ceil: $value diff --git a/generator/config/expression/cmp.yaml b/generator/config/expression/cmp.yaml index dd24f9839..6125fe27c 100644 --- a/generator/config/expression/cmp.yaml +++ b/generator/config/expression/cmp.yaml @@ -1,31 +1,27 @@ # $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 description: | Returns 0 if the two values are equivalent, 1 if the first value is greater than the second, and -1 if the first value is less than the second. arguments: - - - name: expression1 - type: - - expression - - - name: expression2 - type: - - expression + - name: expression1 + type: + - expression + - name: expression2 + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/#example' - pipeline: - - - $project: - item: 1 - qty: 1 - cmpTo250: - $cmp: - - '$qty' - - 250 - _id: 0 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/#example + pipeline: + - $project: + item: 1 + qty: 1 + cmpTo250: + $cmp: + - $qty + - 250 + _id: 0 diff --git a/generator/config/expression/concat.yaml b/generator/config/expression/concat.yaml index e8b218d82..d43aef1b5 100644 --- a/generator/config/expression/concat.yaml +++ b/generator/config/expression/concat.yaml @@ -1,26 +1,23 @@ # $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 description: | Concatenates any number of strings. arguments: - - - name: expression - type: - - resolvesToString - variadic: array + - name: expression + type: + - resolvesToString + variadic: array tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/#examples' - pipeline: - - - $project: - itemDescription: - $concat: - - '$item' - - ' - ' - - '$description' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/#examples + pipeline: + - $project: + itemDescription: + $concat: + - $item + - ' - ' + - $description diff --git a/generator/config/expression/concatArrays.yaml b/generator/config/expression/concatArrays.yaml index 026541092..0a90614e1 100644 --- a/generator/config/expression/concatArrays.yaml +++ b/generator/config/expression/concatArrays.yaml @@ -1,25 +1,22 @@ # $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 description: | Concatenates arrays to return the concatenated array. arguments: - - - name: array - type: - - resolvesToArray - variadic: array + - name: array + type: + - resolvesToArray + variadic: array tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/#example' - pipeline: - - - $project: - items: - $concatArrays: - - '$instock' - - '$ordered' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/#example + pipeline: + - $project: + items: + $concatArrays: + - $instock + - $ordered diff --git a/generator/config/expression/cond.yaml b/generator/config/expression/cond.yaml index e2fd66ad7..2512737f5 100644 --- a/generator/config/expression/cond.yaml +++ b/generator/config/expression/cond.yaml @@ -1,37 +1,32 @@ # $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 description: | A ternary operator that evaluates one expression, and depending on the result, returns the value of one of the other two expressions. Accepts either three expressions in an ordered list or three named parameters. arguments: - - - name: if - type: - - resolvesToBool - - - name: then - type: - - expression - - - name: else - type: - - expression + - name: if + type: + - resolvesToBool + - name: then + type: + - expression + - name: else + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/#example' - pipeline: - - - $project: - item: 1 - discount: - $cond: - if: - $gte: - - '$qty' - - 250 - then: 30 - else: 20 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/#example + pipeline: + - $project: + item: 1 + discount: + $cond: + if: + $gte: + - $qty + - 250 + then: 30 + else: 20 diff --git a/generator/config/expression/convert.yaml b/generator/config/expression/convert.yaml index a76311ed5..84a4e90db 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 @@ -8,75 +8,63 @@ description: | Converts a value to a specified type. New in MongoDB 4.0. arguments: - - - name: input - type: - - expression - - - name: to - type: - - resolvesToString - - resolvesToInt - - - name: onError - type: - - expression - optional: true - description: | - The value to return on encountering an error during conversion, including unsupported type conversions. The arguments can be any valid expression. - If unspecified, the operation throws an error upon encountering an error and stops. - - - name: onNull - type: - - expression - optional: true - description: | - The value to return if the input is null or missing. The arguments can be any valid expression. - If unspecified, $convert returns null if the input is null or missing. + - name: input + type: + - expression + - name: to + type: + - resolvesToString + - resolvesToInt + - name: onError + type: + - expression + optional: true + description: | + The value to return on encountering an error during conversion, including unsupported type conversions. The arguments can be any valid expression. + If unspecified, the operation throws an error upon encountering an error and stops. + - name: onNull + type: + - expression + optional: true + description: | + The value to return if the input is null or missing. The arguments can be any valid expression. + 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' - pipeline: - - - $addFields: - convertedPrice: - $convert: - input: '$price' - to: 'decimal' - onError: 'Error' - onNull: !bson_decimal128 '0' - convertedQty: - $convert: - input: '$qty' - to: 'int' - onError: - $concat: - - 'Could not convert ' - - - $toString: '$qty' - - ' to type integer.' - onNull: 0 - - - $project: - totalPrice: - $switch: - branches: - - - case: - $eq: - - - $type: '$convertedPrice' - - 'string' - then: 'NaN' - - - case: - $eq: - - - $type: '$convertedQty' - - 'string' - then: 'NaN' - default: - $multiply: - - '$convertedPrice' - - '$convertedQty' + - 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' + convertedQty: + $convert: + input: $qty + to: int + onError: + $concat: + - 'Could not convert ' + - $toString: $qty + - ' to type integer.' + onNull: 0 + - $project: + totalPrice: + $switch: + branches: + - case: + $eq: + - $type: $convertedPrice + - string + then: NaN + - case: + $eq: + - $type: $convertedQty + - string + then: NaN + default: + $multiply: + - $convertedPrice + - $convertedQty diff --git a/generator/config/expression/cos.yaml b/generator/config/expression/cos.yaml index 0b47670cf..bcd35d042 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 @@ -8,23 +8,19 @@ encode: single description: | Returns the cosine of a value that is measured in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $cos takes any valid expression that resolves to a number. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the result to radians. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $cos takes any valid expression that resolves to a number. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the result to radians. + 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' - pipeline: - - - $addFields: - side_a: - $multiply: - - - $cos: - $degreesToRadians: '$angle_a' - - '$hypotenuse' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cos/#example + pipeline: + - $addFields: + side_a: + $multiply: + - $cos: + $degreesToRadians: $angle_a + - $hypotenuse diff --git a/generator/config/expression/cosh.yaml b/generator/config/expression/cosh.yaml index 419fa8caa..73a02a01d 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 @@ -8,20 +8,17 @@ encode: single description: | Returns the hyperbolic cosine of a value that is measured in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $cosh takes any valid expression that resolves to a number, measured in radians. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the value to radians. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $cosh takes any valid expression that resolves to a number, measured in radians. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the value to radians. + 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' - pipeline: - - - $addFields: - cosh_output: - $cosh: - $degreesToRadians: '$angle' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/cosh/#example + pipeline: + - $addFields: + cosh_output: + $cosh: + $degreesToRadians: $angle diff --git a/generator/config/expression/dateAdd.yaml b/generator/config/expression/dateAdd.yaml index c7d85d571..b4b494cb2 100644 --- a/generator/config/expression/dateAdd.yaml +++ b/generator/config/expression/dateAdd.yaml @@ -1,133 +1,120 @@ # $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 description: | Adds a number of time units to a date object. arguments: - - - name: startDate - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The beginning date, in UTC, for the addition operation. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: unit - type: - - timeUnit - description: | - The unit used to measure the amount of time added to the startDate. - - - name: amount - type: - - resolvesToInt - - resolvesToLong - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: startDate + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The beginning date, in UTC, for the addition operation. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: unit + type: + - timeUnit + description: | + The unit used to measure the amount of time added to the startDate. + - name: amount + type: + - resolvesToInt + - resolvesToLong + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - expectedDeliveryDate: - $dateAdd: - startDate: '$purchaseDate' - unit: 'day' - amount: 3 - - + - 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 + amount: 3 # Example uses the short form, the builder always generates the verbose form # $merge: 'shipping' - $merge: - into: 'shipping' - - - 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' - - - $dateAdd: - startDate: '$purchaseDate' - unit: 'day' - amount: 5 - - - $project: - _id: 0 - custId: 1 - purchased: - $dateToString: - format: '%Y-%m-%d' - date: '$purchaseDate' - delivery: - $dateToString: - format: '%Y-%m-%d' - date: '$deliveryDate' - - - name: 'Adjust for Daylight Savings Time' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/#adjust-for-daylight-savings-time' - pipeline: - - - $project: - _id: 0 - location: 1 - start: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: '$login' - days: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: - $dateAdd: - startDate: '$login' - unit: 'day' - amount: 1 - timezone: '$location' - hours: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: - $dateAdd: - startDate: '$login' - unit: 'hour' - amount: 24 - timezone: '$location' - startTZInfo: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: '$login' - timezone: '$location' - daysTZInfo: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: - $dateAdd: - startDate: '$login' - unit: 'day' - amount: 1 - timezone: '$location' - timezone: '$location' - hoursTZInfo: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: - $dateAdd: - startDate: '$login' - unit: 'hour' - amount: 24 - timezone: '$location' - timezone: '$location' + - $merge: + into: shipping + - 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 + - $dateAdd: + startDate: $purchaseDate + unit: day + amount: 5 + - $project: + _id: 0 + custId: 1 + purchased: + $dateToString: + format: '%Y-%m-%d' + date: $purchaseDate + delivery: + $dateToString: + format: '%Y-%m-%d' + date: $deliveryDate + - name: Adjust for Daylight Savings Time + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/#adjust-for-daylight-savings-time + pipeline: + - $project: + _id: 0 + location: 1 + start: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: $login + days: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: + $dateAdd: + startDate: $login + unit: day + amount: 1 + timezone: $location + hours: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: + $dateAdd: + startDate: $login + unit: hour + amount: 24 + timezone: $location + startTZInfo: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: $login + timezone: $location + daysTZInfo: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: + $dateAdd: + startDate: $login + unit: day + amount: 1 + timezone: $location + timezone: $location + hoursTZInfo: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: + $dateAdd: + startDate: $login + unit: hour + amount: 24 + timezone: $location + timezone: $location diff --git a/generator/config/expression/dateDiff.yaml b/generator/config/expression/dateDiff.yaml index 42cb55d15..c001a11d6 100644 --- a/generator/config/expression/dateDiff.yaml +++ b/generator/config/expression/dateDiff.yaml @@ -1,114 +1,102 @@ # $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 description: | Returns the difference between two dates. arguments: - - - name: startDate - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The start of the time period. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: endDate - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The end of the time period. The endDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: unit - type: - - timeUnit - description: | - The time measurement unit between the startDate and endDate - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. - - - name: startOfWeek - type: - - resolvesToString - optional: true - description: | - Used when the unit is equal to week. Defaults to Sunday. The startOfWeek parameter is an expression that resolves to a case insensitive string + - name: startDate + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The start of the time period. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: endDate + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The end of the time period. The endDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: unit + type: + - timeUnit + description: | + The time measurement unit between the startDate and endDate + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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. + - name: startOfWeek + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $group: - _id: ~ - averageTime: - $avg: - $dateDiff: - startDate: '$purchased' - endDate: '$delivered' - unit: 'day' - - - $project: - _id: 0 - numDays: - $trunc: - - '$averageTime' - - 1 - - - name: 'Result Precision' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/#result-precision' - pipeline: - - - $project: - Start: '$start' - End: '$end' - years: + - name: Elapsed Time + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/#elapsed-time + pipeline: + - $group: + _id: ~ + averageTime: + $avg: $dateDiff: - startDate: '$start' - endDate: '$end' - unit: 'year' - months: - $dateDiff: - startDate: '$start' - endDate: '$end' - unit: 'month' - days: - $dateDiff: - startDate: '$start' - endDate: '$end' - unit: 'day' - _id: 0 - - - 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' - wks_monday: - $dateDiff: - startDate: '$start' - endDate: '$end' - unit: 'week' - startOfWeek: 'Monday' - wks_friday: - $dateDiff: - startDate: '$start' - endDate: '$end' - unit: 'week' - startOfWeek: 'fri' - _id: 0 + startDate: $purchased + endDate: $delivered + unit: day + - $project: + _id: 0 + numDays: + $trunc: + - $averageTime + - 1 + - name: Result Precision + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/#result-precision + pipeline: + - $project: + Start: $start + End: $end + years: + $dateDiff: + startDate: $start + endDate: $end + unit: year + months: + $dateDiff: + startDate: $start + endDate: $end + unit: month + days: + $dateDiff: + startDate: $start + endDate: $end + unit: day + _id: 0 + - 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 + wks_monday: + $dateDiff: + startDate: $start + endDate: $end + unit: week + startOfWeek: Monday + wks_friday: + $dateDiff: + startDate: $start + endDate: $end + unit: week + startOfWeek: fri + _id: 0 diff --git a/generator/config/expression/dateFromParts.yaml b/generator/config/expression/dateFromParts.yaml index 3ed35004e..b1beaf91a 100644 --- a/generator/config/expression/dateFromParts.yaml +++ b/generator/config/expression/dateFromParts.yaml @@ -1,114 +1,101 @@ # $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 description: | Constructs a BSON Date object given the date's constituent parts. arguments: - - - name: year - type: - - resolvesToNumber - optional: true - description: | - Calendar year. Can be any expression that evaluates to a number. - - - name: isoWeekYear - type: - - resolvesToNumber - optional: true - description: | - ISO Week Date Year. Can be any expression that evaluates to a number. - - - name: month - type: - - resolvesToNumber - optional: true - description: | - Month. Defaults to 1. - - - name: isoWeek - type: - - resolvesToNumber - optional: true - description: | - Week of year. Defaults to 1. - - - name: day - type: - - resolvesToNumber - optional: true - description: | - Day of month. Defaults to 1. - - - name: isoDayOfWeek - type: - - resolvesToNumber - optional: true - description: | - Day of week (Monday 1 - Sunday 7). Defaults to 1. - - - name: hour - type: - - resolvesToNumber - optional: true - description: | - Hour. Defaults to 0. - - - name: minute - type: - - resolvesToNumber - optional: true - description: | - Minute. Defaults to 0. - - - name: second - type: - - resolvesToNumber - optional: true - description: | - Second. Defaults to 0. - - - name: millisecond - type: - - resolvesToNumber - optional: true - description: | - Millisecond. Defaults to 0. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: year + type: + - resolvesToNumber + optional: true + description: | + Calendar year. Can be any expression that evaluates to a number. + - name: isoWeekYear + type: + - resolvesToNumber + optional: true + description: | + ISO Week Date Year. Can be any expression that evaluates to a number. + - name: month + type: + - resolvesToNumber + optional: true + description: | + Month. Defaults to 1. + - name: isoWeek + type: + - resolvesToNumber + optional: true + description: | + Week of year. Defaults to 1. + - name: day + type: + - resolvesToNumber + optional: true + description: | + Day of month. Defaults to 1. + - name: isoDayOfWeek + type: + - resolvesToNumber + optional: true + description: | + Day of week (Monday 1 - Sunday 7). Defaults to 1. + - name: hour + type: + - resolvesToNumber + optional: true + description: | + Hour. Defaults to 0. + - name: minute + type: + - resolvesToNumber + optional: true + description: | + Minute. Defaults to 0. + - name: second + type: + - resolvesToNumber + optional: true + description: | + Second. Defaults to 0. + - name: millisecond + type: + - resolvesToNumber + optional: true + description: | + Millisecond. Defaults to 0. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - date: - $dateFromParts: - year: 2017 - month: 2 - day: 8 - hour: 12 - date_iso: - $dateFromParts: - isoWeekYear: 2017 - isoWeek: 6 - isoDayOfWeek: 3 - hour: 12 - date_timezone: - $dateFromParts: - year: 2016 - month: 12 - day: 31 - hour: 23 - minute: 46 - second: 12 - timezone: 'America/New_York' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromParts/#example + pipeline: + - $project: + date: + $dateFromParts: + year: 2017 + month: 2 + day: 8 + hour: 12 + date_iso: + $dateFromParts: + isoWeekYear: 2017 + isoWeek: 6 + isoDayOfWeek: 3 + hour: 12 + date_timezone: + $dateFromParts: + year: 2016 + month: 12 + day: 31 + hour: 23 + minute: 46 + second: 12 + timezone: America/New_York diff --git a/generator/config/expression/dateFromString.yaml b/generator/config/expression/dateFromString.yaml index 713200f5d..c7d44a6ad 100644 --- a/generator/config/expression/dateFromString.yaml +++ b/generator/config/expression/dateFromString.yaml @@ -1,80 +1,68 @@ # $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 description: | Converts a date/time string to a date object. arguments: - - - name: dateString - type: - - resolvesToString - description: | - The date/time string to convert to a date object. - - - name: format - type: - - resolvesToString - optional: true - description: | - The date format specification of the dateString. The format can be any expression that evaluates to a string literal, containing 0 or more format specifiers. - If unspecified, $dateFromString uses "%Y-%m-%dT%H:%M:%S.%LZ" as the default format but accepts a variety of formats and attempts to parse the dateString if possible. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - The time zone to use to format the date. - - - name: onError - type: - - expression - optional: true - description: | - If $dateFromString encounters an error while parsing the given dateString, it outputs the result value of the provided onError expression. This result value can be of any type. - If you do not specify onError, $dateFromString throws an error if it cannot parse dateString. - - - name: onNull - type: - - expression - optional: true - description: | - If the dateString provided to $dateFromString is null or missing, it outputs the result value of the provided onNull expression. This result value can be of any type. - If you do not specify onNull and dateString is null or missing, then $dateFromString outputs null. + - name: dateString + type: + - resolvesToString + description: | + The date/time string to convert to a date object. + - name: format + type: + - resolvesToString + optional: true + description: | + The date format specification of the dateString. The format can be any expression that evaluates to a string literal, containing 0 or more format specifiers. + If unspecified, $dateFromString uses "%Y-%m-%dT%H:%M:%S.%LZ" as the default format but accepts a variety of formats and attempts to parse the dateString if possible. + - name: timezone + type: + - resolvesToString + optional: true + description: | + The time zone to use to format the date. + - name: onError + type: + - expression + optional: true + description: | + If $dateFromString encounters an error while parsing the given dateString, it outputs the result value of the provided onError expression. This result value can be of any type. + If you do not specify onError, $dateFromString throws an error if it cannot parse dateString. + - name: onNull + type: + - expression + optional: true + description: | + If the dateString provided to $dateFromString is null or missing, it outputs the result value of the provided onNull expression. This result value can be of any type. + 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' - pipeline: - - - $project: - date: - $dateFromString: - dateString: '$date' - timezone: 'America/New_York' - - - name: 'onError' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/#onerror' - pipeline: - - - $project: - date: - $dateFromString: - dateString: '$date' - timezone: '$timezone' - onError: '$date' - - - 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 - + - 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 + - name: onError + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/#onerror + pipeline: + - $project: + date: + $dateFromString: + dateString: $date + timezone: $timezone + onError: $date + - 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 diff --git a/generator/config/expression/dateSubtract.yaml b/generator/config/expression/dateSubtract.yaml index e463fe8f8..5d2a85238 100644 --- a/generator/config/expression/dateSubtract.yaml +++ b/generator/config/expression/dateSubtract.yaml @@ -1,139 +1,124 @@ # $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 description: | Subtracts a number of time units from a date object. arguments: - - - name: startDate - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The beginning date, in UTC, for the addition operation. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: unit - type: - - timeUnit - description: | - The unit used to measure the amount of time added to the startDate. - - - name: amount - type: - - resolvesToInt - - resolvesToLong - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: startDate + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The beginning date, in UTC, for the addition operation. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: unit + type: + - timeUnit + description: | + The unit used to measure the amount of time added to the startDate. + - name: amount + type: + - resolvesToInt + - resolvesToLong + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $match: - $expr: - $eq: - - + - 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' - - 1 - - - $project: - logoutTime: - $dateSubtract: - startDate: '$logout' - unit: 'hour' - amount: 3 - - + - $month: + date: $logout + - 1 + - $project: + logoutTime: + $dateSubtract: + startDate: $logout + unit: hour + amount: 3 # Example uses the short form, the builder always generates the verbose form # $merge: 'connectionTime' - $merge: - into: 'connectionTime' - - - 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' - - - $dateSubtract: - startDate: '$$NOW' - unit: 'week' - amount: 1 - - - $project: - _id: 0 - custId: 1 - loggedOut: - $dateToString: - format: '%Y-%m-%d' - date: '$logoutTime' - - - name: 'Adjust for Daylight Savings Time' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/#adjust-for-daylight-savings-time' - pipeline: - - - $project: - _id: 0 - location: 1 - start: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: '$login' - days: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: - $dateSubtract: - startDate: '$login' - unit: 'day' - amount: 1 - timezone: '$location' - hours: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: - $dateSubtract: - startDate: '$login' - unit: 'hour' - amount: 24 - timezone: '$location' - startTZInfo: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: '$login' - timezone: '$location' - daysTZInfo: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: - $dateSubtract: - startDate: '$login' - unit: 'day' - amount: 1 - timezone: '$location' - timezone: '$location' - hoursTZInfo: - $dateToString: - format: '%Y-%m-%d %H:%M' - date: - $dateSubtract: - startDate: '$login' - unit: 'hour' - amount: 24 - timezone: '$location' - timezone: '$location' + - $merge: + into: connectionTime + - 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 + - $dateSubtract: + startDate: $$NOW + unit: week + amount: 1 + - $project: + _id: 0 + custId: 1 + loggedOut: + $dateToString: + format: '%Y-%m-%d' + date: $logoutTime + - name: Adjust for Daylight Savings Time + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/#adjust-for-daylight-savings-time + pipeline: + - $project: + _id: 0 + location: 1 + start: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: $login + days: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: + $dateSubtract: + startDate: $login + unit: day + amount: 1 + timezone: $location + hours: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: + $dateSubtract: + startDate: $login + unit: hour + amount: 24 + timezone: $location + startTZInfo: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: $login + timezone: $location + daysTZInfo: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: + $dateSubtract: + startDate: $login + unit: day + amount: 1 + timezone: $location + timezone: $location + hoursTZInfo: + $dateToString: + format: '%Y-%m-%d %H:%M' + date: + $dateSubtract: + startDate: $login + unit: hour + amount: 24 + timezone: $location + timezone: $location diff --git a/generator/config/expression/dateToParts.yaml b/generator/config/expression/dateToParts.yaml index d250e052f..ea77f7dcd 100644 --- a/generator/config/expression/dateToParts.yaml +++ b/generator/config/expression/dateToParts.yaml @@ -1,49 +1,44 @@ # $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 description: | Returns a document containing the constituent parts of a date. arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The input date for which to return parts. date can be any expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. - - - name: iso8601 - type: - - bool - optional: true - description: | - If set to true, modifies the output document to use ISO week date fields. Defaults to false. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The input date for which to return parts. date can be any expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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. + - name: iso8601 + type: + - bool + optional: true + description: | + 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' - pipeline: - - - $project: - date: - $dateToParts: - date: '$date' - date_iso: - $dateToParts: - date: '$date' - iso8601: true - date_timezone: - $dateToParts: - date: '$date' - timezone: 'America/New_York' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToParts/#example + pipeline: + - $project: + date: + $dateToParts: + date: $date + date_iso: + $dateToParts: + date: $date + iso8601: true + date_timezone: + $dateToParts: + date: $date + timezone: America/New_York diff --git a/generator/config/expression/dateToString.yaml b/generator/config/expression/dateToString.yaml index 29e0ea8c8..241db86a3 100644 --- a/generator/config/expression/dateToString.yaml +++ b/generator/config/expression/dateToString.yaml @@ -1,81 +1,75 @@ # $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 description: | Returns the date as a formatted string. arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to convert to string. Must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: format - type: - - resolvesToString - optional: true - description: | - The date format specification of the dateString. The format can be any expression that evaluates to a string literal, containing 0 or more format specifiers. - If unspecified, $dateFromString uses "%Y-%m-%dT%H:%M:%S.%LZ" as the default format but accepts a variety of formats and attempts to parse the dateString if possible. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - The time zone to use to format the date. - - - name: onNull - type: - - expression - optional: true - description: | - The value to return if the date is null or missing. - If unspecified, $dateToString returns null if the date is null or missing. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to convert to string. Must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: format + type: + - resolvesToString + optional: true + description: | + The date format specification of the dateString. The format can be any expression that evaluates to a string literal, containing 0 or more format specifiers. + If unspecified, $dateFromString uses "%Y-%m-%dT%H:%M:%S.%LZ" as the default format but accepts a variety of formats and attempts to parse the dateString if possible. + - name: timezone + type: + - resolvesToString + optional: true + description: | + The time zone to use to format the date. + - name: onNull + type: + - expression + optional: true + description: | + The value to return if the date is null or missing. + 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' - pipeline: - - - $project: - yearMonthDayUTC: - $dateToString: - format: '%Y-%m-%d' - date: '$date' - timewithOffsetNY: - $dateToString: - format: '%H:%M:%S:%L%z' - date: '$date' - timezone: 'America/New_York' - timewithOffset430: - $dateToString: - format: '%H:%M:%S:%L%z' - date: '$date' - timezone: '+04:30' - minutesOffsetNY: - $dateToString: - format: '%Z' - date: '$date' - timezone: 'America/New_York' - minutesOffset430: - $dateToString: - format: '%Z' - date: '$date' - timezone: '+04:30' - abbreviated_month: - $dateToString: - format: '%b' - date: '$date' - timezone: '+04:30' - full_month: - $dateToString: - format: '%B' - date: '$date' - timezone: '+04:30' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/#example + pipeline: + - $project: + yearMonthDayUTC: + $dateToString: + format: '%Y-%m-%d' + date: $date + timewithOffsetNY: + $dateToString: + format: '%H:%M:%S:%L%z' + date: $date + timezone: America/New_York + timewithOffset430: + $dateToString: + format: '%H:%M:%S:%L%z' + date: $date + timezone: +04:30 + minutesOffsetNY: + $dateToString: + format: '%Z' + date: $date + timezone: America/New_York + minutesOffset430: + $dateToString: + format: '%Z' + date: $date + timezone: +04:30 + abbreviated_month: + $dateToString: + format: '%b' + date: $date + timezone: +04:30 + full_month: + $dateToString: + format: '%B' + date: $date + timezone: +04:30 diff --git a/generator/config/expression/dateTrunc.yaml b/generator/config/expression/dateTrunc.yaml index aa3dcd6ca..ae42a0982 100644 --- a/generator/config/expression/dateTrunc.yaml +++ b/generator/config/expression/dateTrunc.yaml @@ -1,77 +1,68 @@ # $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 description: | Truncates a date. arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to truncate, specified in UTC. The date can be any expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: unit - type: - - timeUnit - description: | - The unit of time, specified as an expression that must resolve to one of these strings: year, quarter, week, month, day, hour, minute, second. - Together, binSize and unit specify the time period used in the $dateTrunc calculation. - - - name: binSize - type: - - resolvesToNumber - optional: true - description: | - The numeric time value, specified as an expression that must resolve to a positive non-zero number. Defaults to 1. - Together, binSize and unit specify the time period used in the $dateTrunc calculation. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. - - - name: startOfWeek - type: - - string - optional: true - description: | - The start of the week. Used when - unit is week. Defaults to Sunday. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to truncate, specified in UTC. The date can be any expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: unit + type: + - timeUnit + description: | + The unit of time, specified as an expression that must resolve to one of these strings: year, quarter, week, month, day, hour, minute, second. + Together, binSize and unit specify the time period used in the $dateTrunc calculation. + - name: binSize + type: + - resolvesToNumber + optional: true + description: | + The numeric time value, specified as an expression that must resolve to a positive non-zero number. Defaults to 1. + Together, binSize and unit specify the time period used in the $dateTrunc calculation. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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. + - name: startOfWeek + type: + - string + optional: true + description: | + The start of the week. Used when + 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' - pipeline: - - - $project: - _id: 1 - orderDate: 1 + - 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: + _id: 1 + orderDate: 1 + truncatedOrderDate: + $dateTrunc: + date: $orderDate + unit: week + binSize: 2 + timezone: America/Los_Angeles + startOfWeek: Monday + - 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: 'week' - binSize: 2 - timezone: 'America/Los_Angeles' - startOfWeek: 'Monday' - - - 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' - binSize: 6 - sumQuantity: - $sum: '$quantity' + date: $orderDate + unit: month + binSize: 6 + sumQuantity: + $sum: $quantity diff --git a/generator/config/expression/dayOfMonth.yaml b/generator/config/expression/dayOfMonth.yaml index 46a4de0b7..6975e03a3 100644 --- a/generator/config/expression/dayOfMonth.yaml +++ b/generator/config/expression/dayOfMonth.yaml @@ -1,36 +1,32 @@ # $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 description: | Returns the day of the month for a date as a number between 1 and 31. arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - day: + - 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' + $dayOfMonth: + date: $date diff --git a/generator/config/expression/dayOfWeek.yaml b/generator/config/expression/dayOfWeek.yaml index 27a6a809d..db658f456 100644 --- a/generator/config/expression/dayOfWeek.yaml +++ b/generator/config/expression/dayOfWeek.yaml @@ -1,36 +1,32 @@ # $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 description: | Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday). arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - dayOfWeek: + - 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' + $dayOfWeek: + date: $date diff --git a/generator/config/expression/dayOfYear.yaml b/generator/config/expression/dayOfYear.yaml index 8caa0374d..a9ede4a8c 100644 --- a/generator/config/expression/dayOfYear.yaml +++ b/generator/config/expression/dayOfYear.yaml @@ -1,36 +1,32 @@ # $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 description: | Returns the day of the year for a date as a number between 1 and 366 (leap year). arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - dayOfYear: + - 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' + $dayOfYear: + date: $date diff --git a/generator/config/expression/degreesToRadians.yaml b/generator/config/expression/degreesToRadians.yaml index 59c18d2e3..bd2257f5c 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 @@ -8,23 +8,20 @@ encode: single description: | Converts a value from degrees to radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $degreesToRadians takes any valid expression that resolves to a number. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $degreesToRadians takes any valid expression that resolves to a number. + 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' - pipeline: - - - $addFields: - angle_a_rad: - $degreesToRadians: '$angle_a' - angle_b_rad: - $degreesToRadians: '$angle_b' - angle_c_rad: - $degreesToRadians: '$angle_c' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/degreesToRadians/#example + pipeline: + - $addFields: + angle_a_rad: + $degreesToRadians: $angle_a + angle_b_rad: + $degreesToRadians: $angle_b + angle_c_rad: + $degreesToRadians: $angle_c diff --git a/generator/config/expression/divide.yaml b/generator/config/expression/divide.yaml index 3b69389d8..880a3ba2e 100644 --- a/generator/config/expression/divide.yaml +++ b/generator/config/expression/divide.yaml @@ -1,31 +1,27 @@ # $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 description: | Returns the result of dividing the first number by the second. Accepts two argument expressions. arguments: - - - name: dividend - type: - - resolvesToNumber - description: | - The first argument is the dividend, and the second argument is the divisor; i.e. the first argument is divided by the second argument. - - - name: divisor - type: - - resolvesToNumber + - name: dividend + type: + - resolvesToNumber + description: | + The first argument is the dividend, and the second argument is the divisor; i.e. the first argument is divided by the second argument. + - name: divisor + type: + - resolvesToNumber tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/#example' - pipeline: - - - $project: - city: 1 - workdays: - $divide: - - '$hours' - - 8 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/#example + pipeline: + - $project: + city: 1 + workdays: + $divide: + - $hours + - 8 diff --git a/generator/config/expression/eq.yaml b/generator/config/expression/eq.yaml index 009280ba1..9ffdaa477 100644 --- a/generator/config/expression/eq.yaml +++ b/generator/config/expression/eq.yaml @@ -1,31 +1,27 @@ # $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 description: | Returns true if the values are equivalent. arguments: - - - name: expression1 - type: - - expression - - - name: expression2 - type: - - expression + - name: expression1 + type: + - expression + - name: expression2 + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/#example' - pipeline: - - - $project: - item: 1 - qty: 1 - qtyEq250: - $eq: - - '$qty' - - 250 - _id: 0 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/#example + pipeline: + - $project: + item: 1 + qty: 1 + qtyEq250: + $eq: + - $qty + - 250 + _id: 0 diff --git a/generator/config/expression/exp.yaml b/generator/config/expression/exp.yaml index d1f6982a1..73b70a724 100644 --- a/generator/config/expression/exp.yaml +++ b/generator/config/expression/exp.yaml @@ -1,25 +1,21 @@ # $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 description: | Raises e to the specified exponent. arguments: - - - name: exponent - type: - - resolvesToNumber + - name: exponent + type: + - resolvesToNumber tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/#example' - pipeline: - - - $project: - effectiveRate: - $subtract: - - - $exp: '$interestRate' - - 1 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/#example + pipeline: + - $project: + effectiveRate: + $subtract: + - $exp: $interestRate + - 1 diff --git a/generator/config/expression/filter.yaml b/generator/config/expression/filter.yaml index 0b72f6d75..43b9964a8 100644 --- a/generator/config/expression/filter.yaml +++ b/generator/config/expression/filter.yaml @@ -1,94 +1,82 @@ # $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 description: | Selects a subset of the array to return an array with only the elements that match the filter condition. arguments: - - - name: input - type: - - resolvesToArray - - - name: cond - type: - - resolvesToBool - description: | - An expression that resolves to a boolean value used to determine if an element should be included in the output array. The expression references each element of the input array individually with the variable name specified in as. - - - name: as - type: - - string - optional: true - description: | - A name for the variable that represents each individual element of the input array. If no name is specified, the variable name defaults to this. - - - name: limit - type: - - resolvesToInt - optional: true - description: | - A number expression that restricts the number of matching array elements that $filter returns. You cannot specify a limit less than 1. The matching array elements are returned in the order they appear in the input array. - 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. + - name: input + type: + - resolvesToArray + - name: cond + type: + - resolvesToBool + description: | + An expression that resolves to a boolean value used to determine if an element should be included in the output array. The expression references each element of the input array individually with the variable name specified in as. + - name: as + type: + - string + optional: true + description: | + A name for the variable that represents each individual element of the input array. If no name is specified, the variable name defaults to this. + - name: limit + type: + - resolvesToInt + optional: true + description: | + A number expression that restricts the number of matching array elements that $filter returns. You cannot specify a limit less than 1. The matching array elements are returned in the order they appear in the input array. + 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' - pipeline: - - - $project: - items: - $filter: - input: '$items' - as: 'item' - cond: - $gte: - - '$$item.price' - - 100 - - - name: 'Using the limit field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#using-the-limit-field' - pipeline: - - - $project: - items: - $filter: - input: '$items' - cond: - $gte: - - '$$item.price' - - 100 - as: 'item' - limit: 1 - - - name: 'limit as a Numeric Expression' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#limit-as-a-numeric-expression' - pipeline: - - - $project: - items: - $filter: - input: '$items' - cond: - $lte: - - '$$item.price' - - 150 - as: 'item' - limit: 2 - - - 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' - cond: - $gte: - - '$$item.price' - - 100 - as: 'item' - limit: 5 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#examples + pipeline: + - $project: + items: + $filter: + input: $items + as: item + cond: + $gte: + - $$item.price + - 100 + - name: Using the limit field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#using-the-limit-field + pipeline: + - $project: + items: + $filter: + input: $items + cond: + $gte: + - $$item.price + - 100 + as: item + limit: 1 + - name: limit as a Numeric Expression + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#limit-as-a-numeric-expression + pipeline: + - $project: + items: + $filter: + input: $items + cond: + $lte: + - $$item.price + - 150 + as: item + limit: 2 + - 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 + cond: + $gte: + - $$item.price + - 100 + as: item + limit: 5 diff --git a/generator/config/expression/first.yaml b/generator/config/expression/first.yaml index 262d340c3..56c5be2ad 100644 --- a/generator/config/expression/first.yaml +++ b/generator/config/expression/first.yaml @@ -1,21 +1,18 @@ # $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 description: | Returns the result of an expression for the first document in an array. arguments: - - - name: expression - type: - - resolvesToArray + - name: expression + type: + - resolvesToArray tests: - - - name: 'Use in $addFields Stage' - pipeline: - - - $addFields: - firstItem: - $first: '$items' + - name: Use in $addFields Stage + pipeline: + - $addFields: + firstItem: + $first: $items diff --git a/generator/config/expression/firstN.yaml b/generator/config/expression/firstN.yaml index e914ff88c..d38727b94 100644 --- a/generator/config/expression/firstN.yaml +++ b/generator/config/expression/firstN.yaml @@ -1,47 +1,42 @@ # $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 description: | Returns a specified number of elements from the beginning of an array. arguments: - - - name: 'n' - type: - - resolvesToInt - description: | - An expression that resolves to a positive integer. The integer specifies the number of array elements that $firstN returns. - - - name: input - type: - - resolvesToArray - description: | - An expression that resolves to the array from which to return n elements. - + - name: n + type: + - resolvesToInt + description: | + An expression that resolves to a positive integer. The integer specifies the number of array elements that $firstN returns. + - name: input + type: + - 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' - pipeline: - - - $addFields: - firstScores: - $firstN: - 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' - pipeline: - - - $documents: - - - array: [10, 20, 30, 40] - - - $project: - firstThreeElements: - $firstN: - input: '$array' - n: 3 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN-array-element/#example + pipeline: + - $addFields: + firstScores: + $firstN: + 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 + pipeline: + - $documents: + - array: + - 10 + - 20 + - 30 + - 40 + - $project: + firstThreeElements: + $firstN: + input: $array + n: 3 diff --git a/generator/config/expression/floor.yaml b/generator/config/expression/floor.yaml index 4c5856264..171c622b5 100644 --- a/generator/config/expression/floor.yaml +++ b/generator/config/expression/floor.yaml @@ -1,23 +1,20 @@ # $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 description: | Returns the largest integer less than or equal to the specified number. arguments: - - - name: expression - type: - - resolvesToNumber + - name: expression + type: + - resolvesToNumber tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/#example' - pipeline: - - - $project: - value: 1 - floorValue: - $floor: '$value' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/#example + pipeline: + - $project: + value: 1 + floorValue: + $floor: $value diff --git a/generator/config/expression/function.yaml b/generator/config/expression/function.yaml index fa4dba8b5..daf6b7b90 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 @@ -8,67 +8,60 @@ description: | Defines a custom function. New in MongoDB 4.4. arguments: - - - name: body - type: - - javascript - description: | - The function definition. You can specify the function definition as either BSON\JavaScript or string. - function(arg1, arg2, ...) { ... } - - - name: args - type: - - array - description: | - Arguments passed to the function body. If the body function does not take an argument, you can specify an empty array [ ]. - default: [] - - - name: lang - type: - - string - default: js + - name: body + type: + - javascript + description: | + The function definition. You can specify the function definition as either BSON\JavaScript or string. + function(arg1, arg2, ...) { ... } + - name: args + type: + - array + description: | + Arguments passed to the function body. If the body function does not take an argument, you can specify an empty array [ ]. + default: [] + - name: lang + type: + - string + default: js tests: - - - name: 'Usage Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#example-1--usage-example' - pipeline: - - - $addFields: - isFound: - $function: - body: - $code: |- - function(name) { - return hex_md5(name) == "15b0a220baa16331e8d80e15367677ad" - } - args: - - '$name' - lang: 'js' - message: - $function: - body: - $code: |- - function(name, scores) { - let total = Array.sum(scores); - return `Hello ${name}. Your total score is ${total}.` - } - args: - - '$name' - - '$scores' - lang: 'js' - - - name: 'Alternative to $where' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#example-2--alternative-to--where' - pipeline: - - - $match: - $expr: - $function: - body: - $code: |- - function(name) { - return hex_md5(name) == "15b0a220baa16331e8d80e15367677ad"; - } - args: - - '$name' - lang: 'js' + - name: Usage Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#example-1--usage-example + pipeline: + - $addFields: + isFound: + $function: + body: + $code: |- + function(name) { + return hex_md5(name) == "15b0a220baa16331e8d80e15367677ad" + } + args: + - $name + lang: js + message: + $function: + body: + $code: |- + function(name, scores) { + let total = Array.sum(scores); + return `Hello ${name}. Your total score is ${total}.` + } + args: + - $name + - $scores + lang: js + - name: Alternative to $where + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#example-2--alternative-to--where + pipeline: + - $match: + $expr: + $function: + body: + $code: |- + function(name) { + return hex_md5(name) == "15b0a220baa16331e8d80e15367677ad"; + } + args: + - $name + lang: js diff --git a/generator/config/expression/getField.yaml b/generator/config/expression/getField.yaml index 04b5d4ace..2b6866893 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 @@ -8,62 +8,51 @@ description: | Returns the value of a specified field from a document. You can use $getField to retrieve the value of fields with names that contain periods (.) or start with dollar signs ($). New in MongoDB 5.0. arguments: - - - name: field - type: - - resolvesToString - description: | - Field in the input object for which you want to return a value. field can be any valid expression that resolves to a string constant. - If field begins with a dollar sign ($), place the field name inside of a $literal expression to return its value. - - - name: input - type: - - expression - optional: true - description: | - Default: $$CURRENT - 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). + - name: field + type: + - resolvesToString + description: | + Field in the input object for which you want to return a value. field can be any valid expression that resolves to a string constant. + If field begins with a dollar sign ($), place the field name inside of a $literal expression to return its value. + - name: input + type: + - expression + optional: true + description: | + Default: $$CURRENT + 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--.-' - pipeline: - - - $match: - $expr: - $gt: - - + - 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' - - 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----' - pipeline: - - - $match: - $expr: - $gt: - - - $getField: + - $getField: + 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---- + pipeline: + - $match: + $expr: + $gt: + - $getField: # Example uses the short form, the builder always generates the verbose form # $literal: '$price' - field: - $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' - pipeline: - - - $match: - $expr: - $lte: - - - $getField: - field: - $literal: '$small' - input: '$quantity' - - 20 + field: + $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 + pipeline: + - $match: + $expr: + $lte: + - $getField: + field: + $literal: $small + input: $quantity + - 20 diff --git a/generator/config/expression/gt.yaml b/generator/config/expression/gt.yaml index da3a35bb2..d1b5e2687 100644 --- a/generator/config/expression/gt.yaml +++ b/generator/config/expression/gt.yaml @@ -1,31 +1,27 @@ # $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 description: | Returns true if the first value is greater than the second. arguments: - - - name: expression1 - type: - - expression - - - name: expression2 - type: - - expression # lack of backreferral is an issue here + - name: expression1 + type: + - expression + - name: expression2 + type: + - expression # lack of backreferral is an issue here tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/#example' - pipeline: - - - $project: - item: 1 - qty: 1 - qtyGt250: - $gt: - - '$qty' - - 250 - _id: 0 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/#example + pipeline: + - $project: + item: 1 + qty: 1 + qtyGt250: + $gt: + - $qty + - 250 + _id: 0 diff --git a/generator/config/expression/gte.yaml b/generator/config/expression/gte.yaml index 6b456daf6..5da36026b 100644 --- a/generator/config/expression/gte.yaml +++ b/generator/config/expression/gte.yaml @@ -1,31 +1,27 @@ # $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 description: | Returns true if the first value is greater than or equal to the second. arguments: - - - name: expression1 - type: - - expression - - - name: expression2 - type: - - expression + - name: expression1 + type: + - expression + - name: expression2 + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/#example' - pipeline: - - - $project: - item: 1 - qty: 1 - qtyGte250: - $gte: - - '$qty' - - 250 - _id: 0 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/#example + pipeline: + - $project: + item: 1 + qty: 1 + qtyGte250: + $gte: + - $qty + - 250 + _id: 0 diff --git a/generator/config/expression/hour.yaml b/generator/config/expression/hour.yaml index ebd62c3a0..aaff160ed 100644 --- a/generator/config/expression/hour.yaml +++ b/generator/config/expression/hour.yaml @@ -1,36 +1,32 @@ # $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 description: | Returns the hour for a date as a number between 0 and 23. arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - hour: + - 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' + $hour: + date: $date diff --git a/generator/config/expression/ifNull.yaml b/generator/config/expression/ifNull.yaml index 9be8e9044..40b9b464c 100644 --- a/generator/config/expression/ifNull.yaml +++ b/generator/config/expression/ifNull.yaml @@ -1,38 +1,33 @@ # $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 description: | Returns either the non-null result of the first expression or the result of the second expression if the first expression results in a null result. Null result encompasses instances of undefined values or missing fields. Accepts two expressions as arguments. The result of the second expression can be null. arguments: - - - name: expression - type: - - expression - variadic: array + - name: expression + type: + - expression + variadic: array tests: - - - 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' - - - 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' + - 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 + - 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 diff --git a/generator/config/expression/in.yaml b/generator/config/expression/in.yaml index 7cef8c149..20e4390dc 100644 --- a/generator/config/expression/in.yaml +++ b/generator/config/expression/in.yaml @@ -1,33 +1,29 @@ # $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 description: | Returns a boolean indicating whether a specified value is in an array. arguments: - - - name: expression - type: - - expression - description: | - Any valid expression expression. - - - name: array - type: - - resolvesToArray - description: | - Any valid expression that resolves to an array. + - name: expression + type: + - expression + description: | + Any valid expression expression. + - name: array + type: + - resolvesToArray + description: | + Any valid expression that resolves to an array. tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/#example' - pipeline: - - - $project: - store location: '$location' - has bananas: - $in: - - 'bananas' - - '$in_stock' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/#example + pipeline: + - $project: + store location: $location + has bananas: + $in: + - bananas + - $in_stock diff --git a/generator/config/expression/indexOfArray.yaml b/generator/config/expression/indexOfArray.yaml index 5840ee0fa..1f8fb45c5 100644 --- a/generator/config/expression/indexOfArray.yaml +++ b/generator/config/expression/indexOfArray.yaml @@ -1,48 +1,42 @@ # $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 description: | Searches an array for an occurrence of a specified value and returns the array index of the first occurrence. Array indexes start at zero. arguments: - - - name: array - type: - - resolvesToArray - description: | - Can be any valid expression as long as it resolves to an array. - If the array expression resolves to a value of null or refers to a field that is missing, $indexOfArray returns null. - If the array expression does not resolve to an array or null nor refers to a missing field, $indexOfArray returns an error. - - - name: search - type: - - expression - - - name: start - type: - - resolvesToInt - optional: true - description: | - An integer, or a number that can be represented as integers (such as 2.0), that specifies the starting index position for the search. Can be any valid expression that resolves to a non-negative integral number. - If unspecified, the starting index position for the search is the beginning of the string. - - - name: end - type: - - resolvesToInt - optional: true - description: | - An integer, or a number that can be represented as integers (such as 2.0), that specifies the ending index position for the search. Can be any valid expression that resolves to a non-negative integral number. If you specify a index value, you should also specify a index value; otherwise, $indexOfArray uses the value as the index value instead of the value. - If unspecified, the ending index position for the search is the end of the string. + - name: array + type: + - resolvesToArray + description: | + Can be any valid expression as long as it resolves to an array. + If the array expression resolves to a value of null or refers to a field that is missing, $indexOfArray returns null. + If the array expression does not resolve to an array or null nor refers to a missing field, $indexOfArray returns an error. + - name: search + type: + - expression + - name: start + type: + - resolvesToInt + optional: true + description: | + An integer, or a number that can be represented as integers (such as 2.0), that specifies the starting index position for the search. Can be any valid expression that resolves to a non-negative integral number. + If unspecified, the starting index position for the search is the beginning of the string. + - name: end + type: + - resolvesToInt + optional: true + description: | + An integer, or a number that can be represented as integers (such as 2.0), that specifies the ending index position for the search. Can be any valid expression that resolves to a non-negative integral number. If you specify a index value, you should also specify a index value; otherwise, $indexOfArray uses the value as the index value instead of the value. + 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' - pipeline: - - - $project: - index: - $indexOfArray: - - '$items' - - 2 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfArray/#example + pipeline: + - $project: + index: + $indexOfArray: + - $items + - 2 diff --git a/generator/config/expression/indexOfBytes.yaml b/generator/config/expression/indexOfBytes.yaml index 7fe890891..0c6f4300f 100644 --- a/generator/config/expression/indexOfBytes.yaml +++ b/generator/config/expression/indexOfBytes.yaml @@ -1,50 +1,44 @@ # $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 description: | Searches a string for an occurrence of a substring and returns the UTF-8 byte index of the first occurrence. If the substring is not found, returns -1. arguments: - - - name: string - type: - - resolvesToString - description: | - Can be any valid expression as long as it resolves to a string. - If the string expression resolves to a value of null or refers to a field that is missing, $indexOfBytes returns null. - If the string expression does not resolve to a string or null nor refers to a missing field, $indexOfBytes returns an error. - - - name: substring - type: - - resolvesToString - description: | - Can be any valid expression as long as it resolves to a string. - - - name: start - type: - - resolvesToInt - optional: true - description: | - An integer, or a number that can be represented as integers (such as 2.0), that specifies the starting index position for the search. Can be any valid expression that resolves to a non-negative integral number. - If unspecified, the starting index position for the search is the beginning of the string. - - - name: end - type: - - resolvesToInt - optional: true - description: | - An integer, or a number that can be represented as integers (such as 2.0), that specifies the ending index position for the search. Can be any valid expression that resolves to a non-negative integral number. If you specify a index value, you should also specify a index value; otherwise, $indexOfArray uses the value as the index value instead of the value. - If unspecified, the ending index position for the search is the end of the string. + - name: string + type: + - resolvesToString + description: | + Can be any valid expression as long as it resolves to a string. + If the string expression resolves to a value of null or refers to a field that is missing, $indexOfBytes returns null. + If the string expression does not resolve to a string or null nor refers to a missing field, $indexOfBytes returns an error. + - name: substring + type: + - resolvesToString + description: | + Can be any valid expression as long as it resolves to a string. + - name: start + type: + - resolvesToInt + optional: true + description: | + An integer, or a number that can be represented as integers (such as 2.0), that specifies the starting index position for the search. Can be any valid expression that resolves to a non-negative integral number. + If unspecified, the starting index position for the search is the beginning of the string. + - name: end + type: + - resolvesToInt + optional: true + description: | + An integer, or a number that can be represented as integers (such as 2.0), that specifies the ending index position for the search. Can be any valid expression that resolves to a non-negative integral number. If you specify a index value, you should also specify a index value; otherwise, $indexOfArray uses the value as the index value instead of the value. + 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' - pipeline: - - - $project: - byteLocation: - $indexOfBytes: - - '$item' - - 'foo' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfBytes/#examples + pipeline: + - $project: + byteLocation: + $indexOfBytes: + - $item + - foo diff --git a/generator/config/expression/indexOfCP.yaml b/generator/config/expression/indexOfCP.yaml index 88ed55ec6..025ef26c8 100644 --- a/generator/config/expression/indexOfCP.yaml +++ b/generator/config/expression/indexOfCP.yaml @@ -1,50 +1,44 @@ # $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 description: | Searches a string for an occurrence of a substring and returns the UTF-8 code point index of the first occurrence. If the substring is not found, returns -1 arguments: - - - name: string - type: - - resolvesToString - description: | - Can be any valid expression as long as it resolves to a string. - If the string expression resolves to a value of null or refers to a field that is missing, $indexOfCP returns null. - If the string expression does not resolve to a string or null nor refers to a missing field, $indexOfCP returns an error. - - - name: substring - type: - - resolvesToString - description: | - Can be any valid expression as long as it resolves to a string. - - - name: start - type: - - resolvesToInt - optional: true - description: | - An integer, or a number that can be represented as integers (such as 2.0), that specifies the starting index position for the search. Can be any valid expression that resolves to a non-negative integral number. - If unspecified, the starting index position for the search is the beginning of the string. - - - name: end - type: - - resolvesToInt - optional: true - description: | - An integer, or a number that can be represented as integers (such as 2.0), that specifies the ending index position for the search. Can be any valid expression that resolves to a non-negative integral number. If you specify a index value, you should also specify a index value; otherwise, $indexOfArray uses the value as the index value instead of the value. - If unspecified, the ending index position for the search is the end of the string. + - name: string + type: + - resolvesToString + description: | + Can be any valid expression as long as it resolves to a string. + If the string expression resolves to a value of null or refers to a field that is missing, $indexOfCP returns null. + If the string expression does not resolve to a string or null nor refers to a missing field, $indexOfCP returns an error. + - name: substring + type: + - resolvesToString + description: | + Can be any valid expression as long as it resolves to a string. + - name: start + type: + - resolvesToInt + optional: true + description: | + An integer, or a number that can be represented as integers (such as 2.0), that specifies the starting index position for the search. Can be any valid expression that resolves to a non-negative integral number. + If unspecified, the starting index position for the search is the beginning of the string. + - name: end + type: + - resolvesToInt + optional: true + description: | + An integer, or a number that can be represented as integers (such as 2.0), that specifies the ending index position for the search. Can be any valid expression that resolves to a non-negative integral number. If you specify a index value, you should also specify a index value; otherwise, $indexOfArray uses the value as the index value instead of the value. + 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' - pipeline: - - - $project: - cpLocation: - $indexOfCP: - - '$item' - - 'foo' + - name: Examples + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfCP/#examples + pipeline: + - $project: + cpLocation: + $indexOfCP: + - $item + - foo diff --git a/generator/config/expression/isArray.yaml b/generator/config/expression/isArray.yaml index b9a5d5cb5..1a0904d28 100644 --- a/generator/config/expression/isArray.yaml +++ b/generator/config/expression/isArray.yaml @@ -1,36 +1,31 @@ # $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 description: | Determines if the operand is an array. Returns a boolean. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/#example' - pipeline: - - - $project: - items: - $cond: - if: - $and: + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/#example + pipeline: + - $project: + items: + $cond: + if: + $and: # Example uses the short form, the builder always generates the verbose form - - - $isArray: - - '$instock' - - - $isArray: - - '$ordered' - then: - $concatArrays: - - '$instock' - - '$ordered' - else: 'One or more fields is not an array.' + - $isArray: + - $instock + - $isArray: + - $ordered + then: + $concatArrays: + - $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..8605b8fbf 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 @@ -9,67 +9,56 @@ description: | Returns boolean false if the expression resolves to any other BSON type, null, or a missing field. New in MongoDB 4.4. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - 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' - pipeline: - - - $addFields: - isNumber: - $isNumber: '$reading' - hasType: - $type: '$reading' - - - 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' - else: - $switch: - branches: - - - case: - $eq: - - '$grade' - - 'A' - then: 4 - - - case: - $eq: - - '$grade' - - 'B' - then: 3 - - - case: - $eq: - - '$grade' - - 'C' - then: 2 - - - case: - $eq: - - '$grade' - - 'D' - then: 1 - - - case: - $eq: - - '$grade' - - 'F' - then: 0 - - - $group: - _id: '$student_id' - GPA: - $avg: '$points' + - 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 + hasType: + $type: $reading + - 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 + else: + $switch: + branches: + - case: + $eq: + - $grade + - A + then: 4 + - case: + $eq: + - $grade + - B + then: 3 + - case: + $eq: + - $grade + - C + then: 2 + - case: + $eq: + - $grade + - D + then: 1 + - case: + $eq: + - $grade + - F + then: 0 + - $group: + _id: $student_id + GPA: + $avg: $points diff --git a/generator/config/expression/isoDayOfWeek.yaml b/generator/config/expression/isoDayOfWeek.yaml index 1956ff5c4..724a112ba 100644 --- a/generator/config/expression/isoDayOfWeek.yaml +++ b/generator/config/expression/isoDayOfWeek.yaml @@ -1,38 +1,34 @@ # $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 description: | Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday). arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - _id: 0 - name: '$name' - dayOfWeek: + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/#example + pipeline: + - $project: + _id: 0 + name: $name + dayOfWeek: # Example uses the short form, the builder always generates the verbose form # $isoDayOfWeek: '$birthday' - $isoDayOfWeek: - date: '$birthday' + $isoDayOfWeek: + date: $birthday diff --git a/generator/config/expression/isoWeek.yaml b/generator/config/expression/isoWeek.yaml index 2958a20c3..e5f9910fd 100644 --- a/generator/config/expression/isoWeek.yaml +++ b/generator/config/expression/isoWeek.yaml @@ -1,38 +1,34 @@ # $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 description: | Returns the week number in ISO 8601 format, ranging from 1 to 53. Week numbers start at 1 with the week (Monday through Sunday) that contains the year's first Thursday. arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - _id: 0 - city: '$city' - weekNumber: + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/#example + pipeline: + - $project: + _id: 0 + city: $city + weekNumber: # Example uses the short form, the builder always generates the verbose form # $isoWeek: '$date' - $isoWeek: - date: '$date' + $isoWeek: + date: $date diff --git a/generator/config/expression/isoWeekYear.yaml b/generator/config/expression/isoWeekYear.yaml index 5dcefa7dd..a63bab1f1 100644 --- a/generator/config/expression/isoWeekYear.yaml +++ b/generator/config/expression/isoWeekYear.yaml @@ -1,36 +1,32 @@ # $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 description: | Returns the year number in ISO 8601 format. The year starts with the Monday of week 1 (ISO 8601) and ends with the Sunday of the last week (ISO 8601). arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - yearNumber: + - 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' + $isoWeekYear: + date: $date diff --git a/generator/config/expression/last.yaml b/generator/config/expression/last.yaml index 2bf18dc7b..4c9ba200f 100644 --- a/generator/config/expression/last.yaml +++ b/generator/config/expression/last.yaml @@ -1,21 +1,18 @@ # $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 description: | Returns the result of an expression for the last document in an array. arguments: - - - name: expression - type: - - resolvesToArray + - name: expression + type: + - resolvesToArray tests: - - - name: 'Use in $addFields Stage' - pipeline: - - - $addFields: - lastItem: - $last: '$items' + - name: Use in $addFields Stage + pipeline: + - $addFields: + lastItem: + $last: $items diff --git a/generator/config/expression/lastN.yaml b/generator/config/expression/lastN.yaml index 0c29ad76e..b3d0ae031 100644 --- a/generator/config/expression/lastN.yaml +++ b/generator/config/expression/lastN.yaml @@ -1,51 +1,42 @@ # $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 description: | Returns a specified number of elements from the end of an array. arguments: - - - name: 'n' - type: - - resolvesToInt - description: | - An expression that resolves to a positive integer. The integer specifies the number of array elements that $firstN returns. - - - name: input - type: - - resolvesToArray - description: | - An expression that resolves to the array from which to return n elements. + - name: n + type: + - resolvesToInt + description: | + An expression that resolves to a positive integer. The integer specifies the number of array elements that $firstN returns. + - name: input + type: + - 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/lastN-array-element/#example' - pipeline: - - - $addFields: - lastScores: - $lastN: - 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' - pipeline: - - - $documents: - - - array: - - 10 - - 20 - - 30 - - 40 - - - $project: - lastThreeElements: - $lastN: - input: '$array' - n: 3 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN-array-element/#example + pipeline: + - $addFields: + lastScores: + $lastN: + 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 + pipeline: + - $documents: + - array: + - 10 + - 20 + - 30 + - 40 + - $project: + lastThreeElements: + $lastN: + input: $array + n: 3 diff --git a/generator/config/expression/let.yaml b/generator/config/expression/let.yaml index 7d3017282..8c9305e6e 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 @@ -8,39 +8,35 @@ description: | Defines variables for use within the scope of a subexpression and returns the result of the subexpression. Accepts named parameters. Accepts any number of argument expressions. arguments: - - - name: vars - type: - - object # of expression - 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. - - - name: in - type: - - expression - description: | - The expression to evaluate. + - name: vars + type: + - object # of expression + 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. + - name: in + type: + - expression + description: | + The expression to evaluate. tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/#example' - pipeline: - - - $project: - finalTotal: - $let: - vars: - total: - $add: - - '$price' - - '$tax' - discounted: - $cond: - if: '$applyDiscount' - then: 0.9 - else: 1 - in: - $multiply: - - '$$total' - - '$$discounted' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/#example + pipeline: + - $project: + finalTotal: + $let: + vars: + total: + $add: + - $price + - $tax + discounted: + $cond: + if: $applyDiscount + then: 0.9 + else: 1 + in: + $multiply: + - $$total + - $$discounted diff --git a/generator/config/expression/literal.yaml b/generator/config/expression/literal.yaml index dfae7bbb3..169986ff9 100644 --- a/generator/config/expression/literal.yaml +++ b/generator/config/expression/literal.yaml @@ -1,15 +1,14 @@ # $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 description: | Return a value without parsing. Use for values that the aggregation pipeline may interpret as an expression. For example, use a $literal expression to a string that starts with a dollar sign ($) to avoid parsing as a field path. arguments: - - - name: value - type: - - any - description: | - If the value is an expression, $literal does not evaluate the expression but instead returns the unparsed expression. + - name: value + type: + - any + description: |- + If the value is an expression, $literal does not evaluate the expression but instead returns the unparsed expression. diff --git a/generator/config/expression/ln.yaml b/generator/config/expression/ln.yaml index f7412aeb9..42c28fe28 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 @@ -8,19 +8,16 @@ description: | Calculates the natural log of a number. $ln is equivalent to $log: [ , Math.E ] expression, where Math.E is a JavaScript representation for Euler's number e. arguments: - - - name: number - type: - - resolvesToNumber - description: | - Any valid expression as long as it resolves to a non-negative number. For more information on expressions, see Expressions. + - name: number + type: + - resolvesToNumber + description: | + 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' - pipeline: - - - $project: - x: '$year' - y: - $ln: '$sales' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ln/#example + pipeline: + - $project: + x: $year + y: + $ln: $sales diff --git a/generator/config/expression/log.yaml b/generator/config/expression/log.yaml index 462eb9492..7d2bfe3e9 100644 --- a/generator/config/expression/log.yaml +++ b/generator/config/expression/log.yaml @@ -1,36 +1,31 @@ # $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 description: | Calculates the log of a number in the specified base. arguments: - - - name: number - type: - - resolvesToNumber - description: | - Any valid expression as long as it resolves to a non-negative number. - - - name: base - type: - - resolvesToNumber - description: | - Any valid expression as long as it resolves to a positive number greater than 1. + - name: number + type: + - resolvesToNumber + description: | + Any valid expression as long as it resolves to a non-negative number. + - name: base + type: + - resolvesToNumber + description: | + 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' - pipeline: - - - $project: - bitsNeeded: - $floor: - $add: - - 1 - - - $log: - - '$int' - - 2 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/#example + pipeline: + - $project: + bitsNeeded: + $floor: + $add: + - 1 + - $log: + - $int + - 2 diff --git a/generator/config/expression/log10.yaml b/generator/config/expression/log10.yaml index 77cab075a..d5ce9faa7 100644 --- a/generator/config/expression/log10.yaml +++ b/generator/config/expression/log10.yaml @@ -1,27 +1,23 @@ # $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 description: | Calculates the log base 10 of a number. arguments: - - - name: number - type: - - resolvesToNumber - description: | - Any valid expression as long as it resolves to a non-negative number. + - name: number + type: + - resolvesToNumber + description: | + 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' - pipeline: - - - $project: - pH: - $multiply: - - -1 - - - $log10: '$H3O' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/#example + pipeline: + - $project: + pH: + $multiply: + - -1 + - $log10: $H3O diff --git a/generator/config/expression/lt.yaml b/generator/config/expression/lt.yaml index 4b7319b97..7e0d72c3a 100644 --- a/generator/config/expression/lt.yaml +++ b/generator/config/expression/lt.yaml @@ -1,31 +1,27 @@ # $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 description: | Returns true if the first value is less than the second. arguments: - - - name: expression1 - type: - - expression - - - name: expression2 - type: - - expression + - name: expression1 + type: + - expression + - name: expression2 + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/#example' - pipeline: - - - $project: - item: 1 - qty: 1 - qtyLt250: - $lt: - - '$qty' - - 250 - _id: 0 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/#example + pipeline: + - $project: + item: 1 + qty: 1 + qtyLt250: + $lt: + - $qty + - 250 + _id: 0 diff --git a/generator/config/expression/lte.yaml b/generator/config/expression/lte.yaml index 91c7b1d88..9d250f4b6 100644 --- a/generator/config/expression/lte.yaml +++ b/generator/config/expression/lte.yaml @@ -1,31 +1,27 @@ # $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 description: | Returns true if the first value is less than or equal to the second. arguments: - - - name: expression1 - type: - - expression - - - name: expression2 - type: - - expression + - name: expression1 + type: + - expression + - name: expression2 + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/#example' - pipeline: - - - $project: - item: 1 - qty: 1 - qtyLte250: - $lte: - - '$qty' - - 250 - _id: 0 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/#example + pipeline: + - $project: + item: 1 + qty: 1 + qtyLte250: + $lte: + - $qty + - 250 + _id: 0 diff --git a/generator/config/expression/ltrim.yaml b/generator/config/expression/ltrim.yaml index 992b70616..cc7f2e450 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 @@ -8,29 +8,25 @@ description: | Removes whitespace or the specified characters from the beginning of a string. New in MongoDB 4.0. arguments: - - - name: input - type: - - resolvesToString - description: | - The string to trim. The argument can be any valid expression that resolves to a string. - - - name: chars - type: - - resolvesToString - optional: true - description: | - The character(s) to trim from the beginning of the input. - The argument can be any valid expression that resolves to a string. The $ltrim operator breaks down the string into individual UTF code point to trim from input. - If unspecified, $ltrim removes whitespace characters, including the null character. + - name: input + type: + - resolvesToString + description: | + The string to trim. The argument can be any valid expression that resolves to a string. + - name: chars + type: + - resolvesToString + optional: true + description: | + The character(s) to trim from the beginning of the input. + The argument can be any valid expression that resolves to a string. The $ltrim operator breaks down the string into individual UTF code point to trim from input. + 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' - pipeline: - - - $project: - item: 1 - description: - $ltrim: - input: '$description' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ltrim/#example + pipeline: + - $project: + item: 1 + description: + $ltrim: + input: $description diff --git a/generator/config/expression/map.yaml b/generator/config/expression/map.yaml index 11db40c24..113f1a353 100644 --- a/generator/config/expression/map.yaml +++ b/generator/config/expression/map.yaml @@ -1,76 +1,66 @@ # $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 description: | Applies a subexpression to each element of an array and returns the array of resulting values in order. Accepts named parameters. arguments: - - - name: input - type: - - resolvesToArray - description: | - An expression that resolves to an array. - - - name: as - type: - - resolvesToString - optional: true - description: | - A name for the variable that represents each individual element of the input array. If no name is specified, the variable name defaults to this. - - - name: in - type: - - expression - description: | - 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. + - name: input + type: + - resolvesToArray + description: | + An expression that resolves to an array. + - name: as + type: + - resolvesToString + optional: true + description: | + A name for the variable that represents each individual element of the input array. If no name is specified, the variable name defaults to this. + - name: in + type: + - expression + description: | + 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' - pipeline: - - - $project: - adjustedGrades: - $map: - input: '$quizzes' - as: 'grade' - in: - $add: - - '$$grade' - - 2 - - - name: 'Truncate Each Array Element' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/#truncate-each-array-element' - pipeline: - - - $project: - city: '$city' - integerValues: - $map: - input: '$distances' - as: 'decimalValue' - in: + - 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 + in: + $add: + - $$grade + - 2 + - name: Truncate Each Array Element + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/#truncate-each-array-element + pipeline: + - $project: + city: $city + integerValues: + $map: + input: $distances + as: decimalValue + in: # Example uses the short form, the builder always generates the verbose form # $trunc: '$$decimalValue' - $trunc: - - '$$decimalValue' - - - 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' - in: - $add: - - - $multiply: - - '$$tempInCelsius' - - 1.8 - - 32 + $trunc: + - $$decimalValue + - 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 + in: + $add: + - $multiply: + - $$tempInCelsius + - 1.8 + - 32 diff --git a/generator/config/expression/max.yaml b/generator/config/expression/max.yaml index b413679c5..9b90d486d 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 @@ -8,28 +8,25 @@ description: | Returns the maximum value that results from applying an expression to each document. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - expression - variadic: array + - name: expression + type: + - expression + variadic: array tests: - - - name: 'Use in $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/#use-in--project-stage' - pipeline: - - - $project: - quizMax: + - 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' - labMax: + $max: + - $quizzes + labMax: # $max: '$labs' - $max: - - '$labs' - examMax: - $max: - - '$final' - - '$midterm' + $max: + - $labs + examMax: + $max: + - $final + - $midterm diff --git a/generator/config/expression/maxN.yaml b/generator/config/expression/maxN.yaml index e0d9d243e..b0a72aa26 100644 --- a/generator/config/expression/maxN.yaml +++ b/generator/config/expression/maxN.yaml @@ -1,32 +1,28 @@ # $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 description: | Returns the n largest values in an array. Distinct from the $maxN accumulator. arguments: - - - name: input - type: - - resolvesToArray - description: | - An expression that resolves to the array from which to return the maximal n elements. - - - name: 'n' - type: - - resolvesToInt - description: | - An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. + - name: input + type: + - resolvesToArray + description: | + An expression that resolves to the array from which to return the maximal n elements. + - name: n + type: + - resolvesToInt + description: | + 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' - pipeline: - - - $addFields: - maxScores: - $maxN: - n: 2 - input: '$score' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN-array-element/#example + pipeline: + - $addFields: + maxScores: + $maxN: + n: 2 + input: $score diff --git a/generator/config/expression/median.yaml b/generator/config/expression/median.yaml index 2aac26a1f..8651af7ab 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 @@ -12,32 +12,28 @@ description: | $setWindowFields It is also available as an aggregation expression. arguments: - - - name: input - type: - - resolvesToNumber - - array # of number - 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. - - - name: method - type: - - accumulatorPercentile - description: | - The method that mongod uses to calculate the 50th percentile value. The method must be 'approximate'. + - name: input + type: + - resolvesToNumber + - array # of number + 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. + - name: method + type: + - accumulatorPercentile + description: | + 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' - pipeline: - - - $project: - _id: 0 - studentId: 1 - testMedians: - $median: - input: - - '$test01' - - '$test02' - - '$test03' - method: 'approximate' + - 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: + _id: 0 + studentId: 1 + testMedians: + $median: + input: + - $test01 + - $test02 + - $test03 + method: approximate diff --git a/generator/config/expression/mergeObjects.yaml b/generator/config/expression/mergeObjects.yaml index 928166852..c4b9418f4 100644 --- a/generator/config/expression/mergeObjects.yaml +++ b/generator/config/expression/mergeObjects.yaml @@ -1,39 +1,33 @@ # $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 description: | Combines multiple documents into a single document. arguments: - - - name: document - type: - - resolvesToObject - variadic: array - description: | - Any valid expression that resolves to a document. + - name: document + type: + - resolvesToObject + variadic: array + description: | + Any valid expression that resolves to a document. tests: - - - name: '$mergeObjects' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/#-mergeobjects' - pipeline: - - - $lookup: - from: 'items' - localField: 'item' - foreignField: 'item' - as: 'fromItems' - - - $replaceRoot: - newRoot: - $mergeObjects: - - - $arrayElemAt: - - '$fromItems' - - 0 - - '$$ROOT' - - - $project: - fromItems: 0 + - name: $mergeObjects + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/#-mergeobjects + pipeline: + - $lookup: + from: items + localField: item + foreignField: item + as: fromItems + - $replaceRoot: + newRoot: + $mergeObjects: + - $arrayElemAt: + - $fromItems + - 0 + - $$ROOT + - $project: + fromItems: 0 diff --git a/generator/config/expression/meta.yaml b/generator/config/expression/meta.yaml index 9a96f7aaf..9d3a0902f 100644 --- a/generator/config/expression/meta.yaml +++ b/generator/config/expression/meta.yaml @@ -1,39 +1,32 @@ # $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 description: | Access available per-document metadata related to the aggregation operation. arguments: - - - name: keyword - type: - - string + - name: keyword + type: + - string tests: - - - name: 'textScore' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/#-meta---textscore-' - pipeline: - - - $match: - $text: - $search: 'cake' - - - $group: - _id: - $meta: 'textScore' - count: - $sum: 1 - - - name: 'indexKey' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/#-meta---indexkey-' - pipeline: - - - $match: - type: 'apparel' - - - $addFields: - idxKey: - $meta: 'indexKey' + - name: textScore + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/#-meta---textscore- + pipeline: + - $match: + $text: + $search: cake + - $group: + _id: + $meta: textScore + count: + $sum: 1 + - name: indexKey + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/#-meta---indexkey- + pipeline: + - $match: + type: apparel + - $addFields: + idxKey: + $meta: indexKey diff --git a/generator/config/expression/millisecond.yaml b/generator/config/expression/millisecond.yaml index af1d26e75..6aface11f 100644 --- a/generator/config/expression/millisecond.yaml +++ b/generator/config/expression/millisecond.yaml @@ -1,36 +1,32 @@ # $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 description: | Returns the milliseconds of a date as a number between 0 and 999. arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - milliseconds: + - 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' + $millisecond: + date: $date diff --git a/generator/config/expression/min.yaml b/generator/config/expression/min.yaml index 1212fd4f7..cce7838f3 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 @@ -8,28 +8,25 @@ description: | Returns the minimum value that results from applying an expression to each document. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - expression - variadic: array + - name: expression + type: + - expression + variadic: array tests: - - - name: 'Use in $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/#use-in--project-stage' - pipeline: - - - $project: - quizMin: + - 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' - labMin: + $min: + - $quizzes + labMin: # $min: '$labs' - $min: - - '$labs' - examMin: - $min: - - '$final' - - '$midterm' + $min: + - $labs + examMin: + $min: + - $final + - $midterm diff --git a/generator/config/expression/minN.yaml b/generator/config/expression/minN.yaml index e7fa8cac1..e53b3c4b0 100644 --- a/generator/config/expression/minN.yaml +++ b/generator/config/expression/minN.yaml @@ -1,32 +1,28 @@ # $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 description: | Returns the n smallest values in an array. Distinct from the $minN accumulator. arguments: - - - name: input - type: - - resolvesToArray - description: | - An expression that resolves to the array from which to return the maximal n elements. - - - name: 'n' - type: - - resolvesToInt - description: | - An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. + - name: input + type: + - resolvesToArray + description: | + An expression that resolves to the array from which to return the maximal n elements. + - name: n + type: + - resolvesToInt + description: | + 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' - pipeline: - - - $addFields: - minScores: - $minN: - n: 2 - input: '$score' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN-array-element/#example + pipeline: + - $addFields: + minScores: + $minN: + n: 2 + input: $score diff --git a/generator/config/expression/minute.yaml b/generator/config/expression/minute.yaml index 109e87f6b..8881b213f 100644 --- a/generator/config/expression/minute.yaml +++ b/generator/config/expression/minute.yaml @@ -1,36 +1,32 @@ # $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 description: | Returns the minute for a date as a number between 0 and 59. arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - minutes: + - 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' + $minute: + date: $date diff --git a/generator/config/expression/mod.yaml b/generator/config/expression/mod.yaml index 0ac48bd54..a5740e687 100644 --- a/generator/config/expression/mod.yaml +++ b/generator/config/expression/mod.yaml @@ -1,30 +1,26 @@ # $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 description: | Returns the remainder of the first number divided by the second. Accepts two argument expressions. arguments: - - - name: dividend - type: - - resolvesToNumber - description: | - The first argument is the dividend, and the second argument is the divisor; i.e. first argument is divided by the second argument. - - - name: divisor - type: - - resolvesToNumber + - name: dividend + type: + - resolvesToNumber + description: | + The first argument is the dividend, and the second argument is the divisor; i.e. first argument is divided by the second argument. + - name: divisor + type: + - resolvesToNumber tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/#example' - pipeline: - - - $project: - remainder: - $mod: - - '$hours' - - '$tasks' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/#example + pipeline: + - $project: + remainder: + $mod: + - $hours + - $tasks diff --git a/generator/config/expression/month.yaml b/generator/config/expression/month.yaml index 7bd383be9..9c36bd234 100644 --- a/generator/config/expression/month.yaml +++ b/generator/config/expression/month.yaml @@ -1,36 +1,32 @@ # $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 description: | Returns the month for a date as a number between 1 (January) and 12 (December). arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - month: + - 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' + $month: + date: $date diff --git a/generator/config/expression/multiply.yaml b/generator/config/expression/multiply.yaml index 5a069cc8c..d0a107b91 100644 --- a/generator/config/expression/multiply.yaml +++ b/generator/config/expression/multiply.yaml @@ -1,30 +1,27 @@ # $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 description: | Multiplies numbers to return the product. Accepts any number of argument expressions. arguments: - - - name: expression - type: - - resolvesToNumber - variadic: array - description: | - The arguments can be any valid expression as long as they resolve to numbers. - Starting in MongoDB 6.1 you can optimize the $multiply operation. To improve performance, group references at the end of the argument list. + - name: expression + type: + - resolvesToNumber + variadic: array + description: | + The arguments can be any valid expression as long as they resolve to numbers. + 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' - pipeline: - - - $project: - date: 1 - item: 1 - total: - $multiply: - - '$price' - - '$quantity' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/#example + pipeline: + - $project: + date: 1 + item: 1 + total: + $multiply: + - $price + - $quantity diff --git a/generator/config/expression/ne.yaml b/generator/config/expression/ne.yaml index da92f1014..cec84134b 100644 --- a/generator/config/expression/ne.yaml +++ b/generator/config/expression/ne.yaml @@ -1,31 +1,27 @@ # $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 description: | Returns true if the values are not equivalent. arguments: - - - name: expression1 - type: - - expression - - - name: expression2 - type: - - expression + - name: expression1 + type: + - expression + - name: expression2 + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/#example' - pipeline: - - - $project: - item: 1 - qty: 1 - qtyNe250: - $ne: - - '$qty' - - 250 - _id: 0 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/#example + pipeline: + - $project: + item: 1 + qty: 1 + qtyNe250: + $ne: + - $qty + - 250 + _id: 0 diff --git a/generator/config/expression/not.yaml b/generator/config/expression/not.yaml index d4e4c90ea..0b2266e3b 100644 --- a/generator/config/expression/not.yaml +++ b/generator/config/expression/not.yaml @@ -1,28 +1,24 @@ # $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 description: | Returns the boolean value that is the opposite of its argument expression. Accepts a single argument expression. arguments: - - - name: expression - type: - - expression - - resolvesToBool + - name: expression + type: + - expression + - resolvesToBool tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/#example' - pipeline: - - - $project: - item: 1 - result: - $not: - - - $gt: - - '$qty' - - 250 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/#example + pipeline: + - $project: + item: 1 + result: + $not: + - $gt: + - $qty + - 250 diff --git a/generator/config/expression/objectToArray.yaml b/generator/config/expression/objectToArray.yaml index 460977f33..a1793779a 100644 --- a/generator/config/expression/objectToArray.yaml +++ b/generator/config/expression/objectToArray.yaml @@ -1,44 +1,37 @@ # $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 description: | Converts a document to an array of documents representing key-value pairs. arguments: - - - name: object - type: - - resolvesToObject - 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. + - name: object + type: + - resolvesToObject + 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' - pipeline: - - - $project: - item: 1 - 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' - pipeline: - - - $project: - warehouses: - $objectToArray: '$instock' - - + - name: $objectToArray Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/#-objecttoarray-example + pipeline: + - $project: + item: 1 + 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 + pipeline: + - $project: + warehouses: + $objectToArray: $instock # Example uses the short form, the builder always generates the verbose form # $unwind: '$warehouses' - $unwind: - path: '$warehouses' - - - $group: - _id: '$warehouses.k' - total: - $sum: '$warehouses.v' + - $unwind: + path: $warehouses + - $group: + _id: $warehouses.k + total: + $sum: $warehouses.v diff --git a/generator/config/expression/or.yaml b/generator/config/expression/or.yaml index 2bbce1910..d349fcb5b 100644 --- a/generator/config/expression/or.yaml +++ b/generator/config/expression/or.yaml @@ -1,33 +1,28 @@ # $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 description: | Returns true when any of its expressions evaluates to true. Accepts any number of argument expressions. arguments: - - - name: expression - type: - - expression - - resolvesToBool - variadic: array + - name: expression + type: + - expression + - resolvesToBool + variadic: array tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/#example' - pipeline: - - - $project: - item: 1 - result: - $or: - - - $gt: - - '$qty' - - 250 - - - $lt: - - '$qty' - - 200 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/#example + pipeline: + - $project: + item: 1 + result: + $or: + - $gt: + - $qty + - 250 + - $lt: + - $qty + - 200 diff --git a/generator/config/expression/percentile.yaml b/generator/config/expression/percentile.yaml index b19fc1904..c98cd12ed 100644 --- a/generator/config/expression/percentile.yaml +++ b/generator/config/expression/percentile.yaml @@ -1,51 +1,48 @@ # $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 encode: object description: | Returns an array of scalar values that correspond to specified percentile values. New in MongoDB 7.0. - This operator is available as an accumulator in these stages: $group - $setWindowFields - It is also available as an aggregation expression. arguments: - - - name: input - type: - - resolvesToNumber - - array # of number - 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 - 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. - - - name: method - type: - - accumulatorPercentile - description: | - The method that mongod uses to calculate the percentile value. The method must be 'approximate'. + - name: input + type: + - resolvesToNumber + - array # of number + 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 + 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. + - name: method + type: + - accumulatorPercentile + description: | + 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' - pipeline: - - - $project: - _id: 0 - studentId: 1 - testPercentiles: - $percentile: - input: ['$test01', '$test02', '$test03'] - p: [0.5, 0.95] - method: 'approximate' + - 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: + _id: 0 + studentId: 1 + testPercentiles: + $percentile: + 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..f66752681 100644 --- a/generator/config/expression/pow.yaml +++ b/generator/config/expression/pow.yaml @@ -1,31 +1,27 @@ # $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 description: | Raises a number to the specified exponent. arguments: - - - name: number - type: - - resolvesToNumber - - - name: exponent - type: - - resolvesToNumber + - name: number + type: + - resolvesToNumber + - name: exponent + type: + - resolvesToNumber tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/pow/#example' - pipeline: - - - $project: - variance: - $pow: - - + - 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'] - - 2 + - $stdDevPop: + - $scores.score + - 2 diff --git a/generator/config/expression/radiansToDegrees.yaml b/generator/config/expression/radiansToDegrees.yaml index be4dd1e1d..e24d6bc9a 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 @@ -8,20 +8,17 @@ encode: single description: | Converts a value from radians to degrees. arguments: - - - name: expression - type: - - resolvesToNumber + - name: expression + type: + - resolvesToNumber tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/#example' - pipeline: - - - $addFields: - angle_a_deg: - $radiansToDegrees: '$angle_a' - angle_b_deg: - $radiansToDegrees: '$angle_b' - angle_c_deg: - $radiansToDegrees: '$angle_c' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/#example + pipeline: + - $addFields: + angle_a_deg: + $radiansToDegrees: $angle_a + angle_b_deg: + $radiansToDegrees: $angle_b + angle_c_deg: + $radiansToDegrees: $angle_c diff --git a/generator/config/expression/rand.yaml b/generator/config/expression/rand.yaml index a19f3163e..d228e9fac 100644 --- a/generator/config/expression/rand.yaml +++ b/generator/config/expression/rand.yaml @@ -1,48 +1,38 @@ # $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 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' - pipeline: - - - $set: - amount: - $multiply: - - - $rand: {} - - 100 - - - $set: - amount: - $floor: '$amount' - - + - name: Generate Random Data Points + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/#generate-random-data-points + pipeline: + - $set: + amount: + $multiply: + - $rand: {} + - 100 + - $set: + amount: + $floor: $amount # Example uses the short form, the builder always generates the verbose form # $merge: 'donors' - $merge: - 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' - pipeline: - - - $match: - district: 3 - - - $match: - $expr: - $lt: - - 0.5 - - - $rand: {} - - - $project: - _id: 0 - name: 1 - registered: 1 + - $merge: + 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 + pipeline: + - $match: + district: 3 + - $match: + $expr: + $lt: + - 0.5 + - $rand: {} + - $project: + _id: 0 + name: 1 + registered: 1 diff --git a/generator/config/expression/range.yaml b/generator/config/expression/range.yaml index 5c78d8898..ebbeed7d7 100644 --- a/generator/config/expression/range.yaml +++ b/generator/config/expression/range.yaml @@ -1,42 +1,37 @@ # $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 encode: array description: | Outputs an array containing a sequence of integers according to user-defined inputs. arguments: - - - name: start - type: - - resolvesToInt - description: | - An integer that specifies the start of the sequence. Can be any valid expression that resolves to an integer. - - - name: end - type: - - resolvesToInt - description: | - An integer that specifies the exclusive upper limit of the sequence. Can be any valid expression that resolves to an integer. - - - name: step - type: - - resolvesToInt - optional: true - description: | - An integer that specifies the increment value. Can be any valid expression that resolves to a non-zero integer. Defaults to 1. + - name: start + type: + - resolvesToInt + description: | + An integer that specifies the start of the sequence. Can be any valid expression that resolves to an integer. + - name: end + type: + - resolvesToInt + description: | + An integer that specifies the exclusive upper limit of the sequence. Can be any valid expression that resolves to an integer. + - name: step + type: + - resolvesToInt + optional: true + description: | + 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' - pipeline: - - - $project: - _id: 0 - city: 1 - Rest stops: - $range: - - 0 - - '$distance' - - 25 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/range/#example + pipeline: + - $project: + _id: 0 + city: 1 + Rest stops: + $range: + - 0 + - $distance + - 25 diff --git a/generator/config/expression/reduce.yaml b/generator/config/expression/reduce.yaml index bf51eabe3..8c5507df1 100644 --- a/generator/config/expression/reduce.yaml +++ b/generator/config/expression/reduce.yaml @@ -1,134 +1,116 @@ # $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 description: | Applies an expression to each element in an array and combines them into a single value. arguments: - - - name: input - type: - - resolvesToArray - description: | - Can be any valid expression that resolves to an array. - If the argument resolves to a value of null or refers to a missing field, $reduce returns null. - If the argument does not resolve to an array or null nor refers to a missing field, $reduce returns an error. - - - name: initialValue - type: - - expression - description: | - The initial cumulative value set before in is applied to the first element of the input array. - - - name: in - type: - - expression - description: | - A valid expression that $reduce applies to each element in the input array in left-to-right order. Wrap the input value with $reverseArray to yield the equivalent of applying the combining expression from right-to-left. - During evaluation of the in expression, two variables will be available: - - value is the variable that represents the cumulative value of the expression. - - this is the variable that refers to the element being processed. + - name: input + type: + - resolvesToArray + description: | + Can be any valid expression that resolves to an array. + If the argument resolves to a value of null or refers to a missing field, $reduce returns null. + If the argument does not resolve to an array or null nor refers to a missing field, $reduce returns an error. + - name: initialValue + type: + - expression + description: | + The initial cumulative value set before in is applied to the first element of the input array. + - name: in + type: + - expression + description: | + A valid expression that $reduce applies to each element in the input array in left-to-right order. Wrap the input value with $reverseArray to yield the equivalent of applying the combining expression from right-to-left. + During evaluation of the in expression, two variables will be available: + - value is the variable that represents the cumulative value of the expression. + - 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' - pipeline: - - - $group: - _id: '$experimentId' - probabilityArr: - $push: '$probability' - - - $project: - description: 1 - results: - $reduce: - input: '$probabilityArr' - initialValue: 1 - in: - $multiply: - - '$$value' - - '$$this' - - - name: 'Discounted Merchandise' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#discounted-merchandise' - pipeline: - - - $project: - discountedPrice: - $reduce: - input: '$discounts' - initialValue: '$price' - in: - $multiply: - - '$$value' - - - $subtract: - - 1 - - '$$this' - - - name: 'String Concatenation' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#string-concatenation' - pipeline: + - name: Multiplication + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#multiplication + pipeline: + - $group: + _id: $experimentId + probabilityArr: + $push: $probability + - $project: + description: 1 + results: + $reduce: + input: $probabilityArr + initialValue: 1 + in: + $multiply: + - $$value + - $$this + - name: Discounted Merchandise + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#discounted-merchandise + pipeline: + - $project: + discountedPrice: + $reduce: + input: $discounts + initialValue: $price + in: + $multiply: + - $$value + - $subtract: + - 1 + - $$this + - 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: - $gt: [] - - - $project: - name: 1 - bio: - $reduce: - input: '$hobbies' - initialValue: 'My hobbies include:' - in: - $concat: - - '$$value' - - - $cond: - if: - $eq: - - '$$value' - - 'My hobbies include:' - then: ' ' - else: ', ' - - '$$this' - - - name: 'Array Concatenation' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#array-concatenation' - pipeline: - - - $project: - collapsed: - $reduce: - input: '$arr' - initialValue: [] - in: + - $match: + hobbies: + $gt: [] + - $project: + name: 1 + bio: + $reduce: + input: $hobbies + initialValue: 'My hobbies include:' + in: + $concat: + - $$value + - $cond: + if: + $eq: + - $$value + - 'My hobbies include:' + then: ' ' + else: ', ' + - $$this + - name: Array Concatenation + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#array-concatenation + pipeline: + - $project: + collapsed: + $reduce: + input: $arr + initialValue: [] + in: + $concatArrays: + - $$value + - $$this + - 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 + initialValue: [] + in: + collapsed: $concatArrays: - - '$$value' - - '$$this' - - - 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' - initialValue: [] - in: - collapsed: - $concatArrays: - - '$$value.collapsed' - - '$$this' - firstValues: - $concatArrays: - - '$$value.firstValues' - - - $slice: - - '$$this' - - 1 + - $$value.collapsed + - $$this + firstValues: + $concatArrays: + - $$value.firstValues + - $slice: + - $$this + - 1 diff --git a/generator/config/expression/regexFind.yaml b/generator/config/expression/regexFind.yaml index d953a4ae6..c4ad11bea 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 @@ -8,59 +8,52 @@ description: | Applies a regular expression (regex) to a string and returns information on the first matched substring. New in MongoDB 4.2. arguments: - - - name: input - type: - - resolvesToString - description: | - The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. - - - name: regex - type: - - resolvesToString - - regex - description: | - The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern //. When using the regex //, you can also specify the regex options i and m (but not the s or x options) - - - name: options - type: - - string - optional: true + - name: input + type: + - resolvesToString + description: | + The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. + - name: regex + type: + - resolvesToString + - regex + description: | + The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern //. When using the regex //, you can also specify the regex options i and m (but not the s or x options) + - name: options + type: + - string + optional: true tests: - - - 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' - - - name: 'i Option' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/#i-option' - pipeline: - - - $addFields: - returnObject: + - 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' + - 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'] - - - $addFields: - returnObject: + $regexFind: + input: $description + regex: !bson_regex + - line + - i + - $addFields: + returnObject: # Specify i in the options field - $regexFind: - input: '$description' - regex: 'line' - options: 'i' - - - $addFields: - returnObject: + $regexFind: + input: $description + regex: line + options: i + - $addFields: + returnObject: # Mix Regex type with options field - $regexFind: - input: '$description' - regex: !bson_regex 'line' - options: 'i' + $regexFind: + input: $description + regex: !bson_regex 'line' + options: i diff --git a/generator/config/expression/regexFindAll.yaml b/generator/config/expression/regexFindAll.yaml index 6aea184d7..3b6166db8 100644 --- a/generator/config/expression/regexFindAll.yaml +++ b/generator/config/expression/regexFindAll.yaml @@ -1,6 +1,6 @@ # $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 encode: object @@ -8,92 +8,83 @@ description: | Applies a regular expression (regex) to a string and returns information on the all matched substrings. New in MongoDB 4.2. arguments: - - - name: input - type: - - resolvesToString - description: | - The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. - - - name: regex - type: - - resolvesToString - - regex - description: | - The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern //. When using the regex //, you can also specify the regex options i and m (but not the s or x options) - - - name: options - type: - - string - optional: true + - name: input + type: + - resolvesToString + description: | + The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. + - name: regex + type: + - resolvesToString + - regex + description: | + The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern //. When using the regex //, you can also specify the regex options i and m (but not the s or x options) + - name: options + type: + - string + optional: true tests: - - - 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' - - - name: 'i Option' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/#i-option' - pipeline: - - - $addFields: - returnObject: + - 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' + - 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'] - - - $addFields: - returnObject: + $regexFindAll: + input: $description + regex: !bson_regex + - line + - i + - $addFields: + returnObject: # Specify i in the options field - $regexFindAll: - input: '$description' - regex: 'line' - options: 'i' - - - $addFields: - returnObject: + $regexFindAll: + input: $description + regex: line + options: i + - $addFields: + returnObject: # Mix Regex type with options field - $regexFindAll: - input: '$description' - regex: !bson_regex 'line' - 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' - pipeline: - - - $addFields: - email: - $regexFindAll: - input: '$comment' - regex: !bson_regex ['[a-z0-9_.+-]+@[a-z0-9_.+-]+\.[a-z0-9_.+-]+', 'i'] - - - $set: - 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' - pipeline: - - - $addFields: - names: - $regexFindAll: - input: '$comment' - regex: !bson_regex ['([a-z0-9_.+-]+)@[a-z0-9_.+-]+\.[a-z0-9_.+-]+', 'i'] - - - $set: - names: - $reduce: - input: '$names.captures' - initialValue: [] - in: - $concatArrays: - - '$$value' - - '$$this' + $regexFindAll: + input: $description + regex: !bson_regex 'line' + 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 + pipeline: + - $addFields: + email: + $regexFindAll: + input: $comment + regex: !bson_regex + - '[a-z0-9_.+-]+@[a-z0-9_.+-]+\.[a-z0-9_.+-]+' + - i + - $set: + 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 + pipeline: + - $addFields: + names: + $regexFindAll: + input: $comment + regex: !bson_regex + - ([a-z0-9_.+-]+)@[a-z0-9_.+-]+\.[a-z0-9_.+-]+ + - i + - $set: + names: + $reduce: + input: $names.captures + initialValue: [] + in: + $concatArrays: + - $$value + - $$this diff --git a/generator/config/expression/regexMatch.yaml b/generator/config/expression/regexMatch.yaml index 4ea9f0aab..eaa6b6489 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 @@ -8,73 +8,66 @@ description: | Applies a regular expression (regex) to a string and returns a boolean that indicates if a match is found or not. New in MongoDB 4.2. arguments: - - - name: input - type: - - resolvesToString - description: | - The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. - - - name: regex - type: - - resolvesToString - - regex - description: | - The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern //. When using the regex //, you can also specify the regex options i and m (but not the s or x options) - - - name: options - type: - - string - optional: true + - name: input + type: + - resolvesToString + description: | + The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. + - name: regex + type: + - resolvesToString + - regex + description: | + The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern //. When using the regex //, you can also specify the regex options i and m (but not the s or x options) + - name: options + type: + - string + optional: true tests: - - - 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' - - - name: 'i Option' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/#i-option' - pipeline: - - - $addFields: - result: + - 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' + - 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'] - - - $addFields: - result: + $regexMatch: + input: $description + regex: !bson_regex + - line + - i + - $addFields: + result: # Specify i in the options field - $regexMatch: - input: '$description' - regex: 'line' - options: 'i' - - - $addFields: - result: + $regexMatch: + input: $description + regex: line + options: i + - $addFields: + result: # Mix Regex type with options field - $regexMatch: - input: '$description' - regex: !bson_regex 'line' - 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' - pipeline: - - - $addFields: - category: - $cond: - if: - $regexMatch: - input: '$comment' - regex: !bson_regex ['[a-z0-9_.+-]+@mongodb.com', 'i'] - then: 'Employee' - else: 'External' + $regexMatch: + input: $description + regex: !bson_regex 'line' + 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 + pipeline: + - $addFields: + category: + $cond: + if: + $regexMatch: + input: $comment + regex: !bson_regex + - '[a-z0-9_.+-]+@mongodb.com' + - i + then: Employee + else: External diff --git a/generator/config/expression/replaceAll.yaml b/generator/config/expression/replaceAll.yaml index 74d479cb7..fceaadbc8 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 @@ -9,36 +9,31 @@ description: | $replaceAll is both case-sensitive and diacritic-sensitive, and ignores any collation present on a collection. New in MongoDB 4.4. arguments: - - - name: input - type: - - resolvesToString - - resolvesToNull - description: | - The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceAll returns null. - - - name: find - type: - - resolvesToString - - resolvesToNull - description: | - The string to search for within the given input. Can be any valid expression that resolves to a string or a null. If find refers to a field that is missing, $replaceAll returns null. - - - name: replacement - type: - - resolvesToString - - resolvesToNull - description: | - 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. + - name: input + type: + - resolvesToString + - resolvesToNull + description: | + The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceAll returns null. + - name: find + type: + - resolvesToString + - resolvesToNull + description: | + The string to search for within the given input. Can be any valid expression that resolves to a string or a null. If find refers to a field that is missing, $replaceAll returns null. + - name: replacement + type: + - resolvesToString + - resolvesToNull + description: | + 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' - pipeline: - - - $project: - item: - $replaceAll: - input: '$item' - find: 'blue paint' - replacement: 'red paint' + - 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 diff --git a/generator/config/expression/replaceOne.yaml b/generator/config/expression/replaceOne.yaml index 0962cc6c5..6c436c9c1 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 @@ -8,36 +8,31 @@ description: | Replaces the first instance of a matched string in a given input. New in MongoDB 4.4. arguments: - - - name: input - type: - - resolvesToString - - resolvesToNull - description: | - The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceAll returns null. - - - name: find - type: - - resolvesToString - - resolvesToNull - description: | - The string to search for within the given input. Can be any valid expression that resolves to a string or a null. If find refers to a field that is missing, $replaceAll returns null. - - - name: replacement - type: - - resolvesToString - - resolvesToNull - description: | - 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. + - name: input + type: + - resolvesToString + - resolvesToNull + description: | + The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceAll returns null. + - name: find + type: + - resolvesToString + - resolvesToNull + description: | + The string to search for within the given input. Can be any valid expression that resolves to a string or a null. If find refers to a field that is missing, $replaceAll returns null. + - name: replacement + type: + - resolvesToString + - resolvesToNull + description: | + 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' - pipeline: - - - $project: - item: - $replaceOne: - input: '$item' - find: 'blue paint' - replacement: 'red paint' + - 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 diff --git a/generator/config/expression/reverseArray.yaml b/generator/config/expression/reverseArray.yaml index 2cbe3f3cd..6e24ec388 100644 --- a/generator/config/expression/reverseArray.yaml +++ b/generator/config/expression/reverseArray.yaml @@ -1,25 +1,22 @@ # $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 description: | Returns an array with the elements in reverse order. arguments: - - - name: expression - type: - - resolvesToArray - description: | - The argument can be any valid expression as long as it resolves to an array. + - name: expression + type: + - resolvesToArray + description: | + 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' - pipeline: - - - $project: - name: 1 - reverseFavorites: - $reverseArray: '$favorites' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reverseArray/#example + pipeline: + - $project: + name: 1 + reverseFavorites: + $reverseArray: $favorites diff --git a/generator/config/expression/round.yaml b/generator/config/expression/round.yaml index 9bc6961c7..516e04bdc 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 @@ -10,41 +10,33 @@ encode: array description: | Rounds a number to a whole integer or to a specified decimal place. arguments: - - - name: number - type: - - resolvesToNumber - description: | - Can be any valid expression that resolves to a number. Specifically, the expression must resolve to an integer, double, decimal, or long. - $round returns an error if the expression resolves to a non-numeric data type. - - - name: place - type: - - resolvesToInt - optional: true - description: | - Can be any valid expression that resolves to an integer between -20 and 100, exclusive. + - name: number + type: + - resolvesToNumber + description: | + Can be any valid expression that resolves to a number. Specifically, the expression must resolve to an integer, double, decimal, or long. + $round returns an error if the expression resolves to a non-numeric data type. + - name: place + type: + - resolvesToInt + optional: true + description: | + 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' - pipeline: - - - $project: - roundedValue: - $round: - - '$value' - - 1 - - - name: 'Round Average Rating' - pipeline: - - - $project: - roundedAverageRating: - $avg: - - - $round: - - - $avg: - - '$averageRating' - - 2 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/#example + pipeline: + - $project: + roundedValue: + $round: + - $value + - 1 + - name: Round Average Rating + pipeline: + - $project: + roundedAverageRating: + $avg: + - $round: + - $avg: + - $averageRating + - 2 diff --git a/generator/config/expression/rtrim.yaml b/generator/config/expression/rtrim.yaml index a9d1974db..3df822042 100644 --- a/generator/config/expression/rtrim.yaml +++ b/generator/config/expression/rtrim.yaml @@ -1,35 +1,31 @@ # $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 description: | Removes whitespace characters, including null, or the specified characters from the end of a string. arguments: - - - name: input - type: - - resolvesToString - description: | - The string to trim. The argument can be any valid expression that resolves to a string. - - - name: chars - type: - - resolvesToString - optional: true - description: | - The character(s) to trim from the beginning of the input. - The argument can be any valid expression that resolves to a string. The $ltrim operator breaks down the string into individual UTF code point to trim from input. - If unspecified, $ltrim removes whitespace characters, including the null character. + - name: input + type: + - resolvesToString + description: | + The string to trim. The argument can be any valid expression that resolves to a string. + - name: chars + type: + - resolvesToString + optional: true + description: | + The character(s) to trim from the beginning of the input. + The argument can be any valid expression that resolves to a string. The $ltrim operator breaks down the string into individual UTF code point to trim from input. + 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' - pipeline: - - - $project: - item: 1 - description: - $rtrim: - input: '$description' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/rtrim/#example + pipeline: + - $project: + item: 1 + description: + $rtrim: + input: $description diff --git a/generator/config/expression/second.yaml b/generator/config/expression/second.yaml index 83e7fd370..ce3ec84bf 100644 --- a/generator/config/expression/second.yaml +++ b/generator/config/expression/second.yaml @@ -1,36 +1,32 @@ # $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 description: | Returns the seconds for a date as a number between 0 and 60 (leap seconds). arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - seconds: + - 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' + $second: + date: $date diff --git a/generator/config/expression/setDifference.yaml b/generator/config/expression/setDifference.yaml index 69f448cb7..e7fc6acea 100644 --- a/generator/config/expression/setDifference.yaml +++ b/generator/config/expression/setDifference.yaml @@ -1,35 +1,31 @@ # $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 description: | Returns a set with elements that appear in the first set but not in the second set; i.e. performs a relative complement of the second set relative to the first. Accepts exactly two argument expressions. arguments: - - - name: expression1 - type: - - resolvesToArray - description: | - The arguments can be any valid expression as long as they each resolve to an array. - - - name: expression2 - type: - - resolvesToArray - description: | - The arguments can be any valid expression as long as they each resolve to an array. + - name: expression1 + type: + - resolvesToArray + description: | + The arguments can be any valid expression as long as they each resolve to an array. + - name: expression2 + type: + - resolvesToArray + description: | + 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' - pipeline: - - - $project: - flowerFieldA: 1 - flowerFieldB: 1 - inBOnly: - $setDifference: - - '$flowerFieldB' - - '$flowerFieldA' - _id: 0 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setDifference/#example + pipeline: + - $project: + flowerFieldA: 1 + flowerFieldB: 1 + inBOnly: + $setDifference: + - $flowerFieldB + - $flowerFieldA + _id: 0 diff --git a/generator/config/expression/setEquals.yaml b/generator/config/expression/setEquals.yaml index 5194c9ae9..de5a6be56 100644 --- a/generator/config/expression/setEquals.yaml +++ b/generator/config/expression/setEquals.yaml @@ -1,28 +1,25 @@ # $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 description: | Returns true if the input sets have the same distinct elements. Accepts two or more argument expressions. arguments: - - - name: expression - type: - - resolvesToArray - variadic: array + - name: expression + type: + - resolvesToArray + variadic: array tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setEquals/#example' - pipeline: - - - $project: - _id: 0 - cakes: 1 - cupcakes: 1 - sameFlavors: - $setEquals: - - '$cakes' - - '$cupcakes' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setEquals/#example + pipeline: + - $project: + _id: 0 + cakes: 1 + cupcakes: 1 + sameFlavors: + $setEquals: + - $cakes + - $cupcakes diff --git a/generator/config/expression/setField.yaml b/generator/config/expression/setField.yaml index b53cf6584..e1661af6c 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 @@ -8,102 +8,83 @@ description: | Adds, updates, or removes a specified field in a document. You can use $setField to add, update, or remove fields with names that contain periods (.) or start with dollar signs ($). New in MongoDB 5.0. arguments: - - - name: field - type: - - resolvesToString - description: | - Field in the input object that you want to add, update, or remove. field can be any valid expression that resolves to a string constant. - - - name: input - type: - - resolvesToObject - description: | - Document that contains the field that you want to add or update. input must resolve to an object, missing, null, or undefined. - - - name: value - type: - - expression - description: | - The value that you want to assign to field. value can be any valid expression. - Set to $$REMOVE to remove field from the input document. + - name: field + type: + - resolvesToString + description: | + Field in the input object that you want to add, update, or remove. field can be any valid expression that resolves to a string constant. + - name: input + type: + - resolvesToObject + description: | + Document that contains the field that you want to add or update. input must resolve to an object, missing, null, or undefined. + - name: value + type: + - expression + description: | + The value that you want to assign to field. value can be any valid expression. + 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--.-' - pipeline: - - - $replaceWith: - $setField: - field: 'price.usd' - input: '$$ROOT' - value: '$price' - - + - 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 # Example uses the short form, the builder always generates the verbose form # $unset: 'price' - $unset: - - '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----' - pipeline: - - - $replaceWith: - $setField: - field: - $literal: '$price' - input: '$$ROOT' - value: '$price' - - + - $unset: + - 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---- + pipeline: + - $replaceWith: + $setField: + field: + $literal: $price + input: $$ROOT + value: $price # Example uses the short form, the builder always generates the verbose form # $unset: 'price' - $unset: - - 'price' - - - name: 'Update Fields that Contain Periods' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#update-fields-that-contain-periods--.-' - pipeline: - - - $match: - _id: 1 - - - $replaceWith: - $setField: - 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----' - pipeline: - - - $match: - _id: 1 - - - $replaceWith: - $setField: - field: - $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--.-' - pipeline: - - - $replaceWith: - $setField: - 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----' - pipeline: - - - $replaceWith: - $setField: - field: - $literal: '$price' - input: '$$ROOT' - value: '$$REMOVE' + - $unset: + - price + - name: Update Fields that Contain Periods + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#update-fields-that-contain-periods--.- + pipeline: + - $match: + _id: 1 + - $replaceWith: + $setField: + 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---- + pipeline: + - $match: + _id: 1 + - $replaceWith: + $setField: + field: + $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--.- + pipeline: + - $replaceWith: + $setField: + 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---- + pipeline: + - $replaceWith: + $setField: + field: + $literal: $price + input: $$ROOT + value: $$REMOVE diff --git a/generator/config/expression/setIntersection.yaml b/generator/config/expression/setIntersection.yaml index 8f03651d5..2ee76717c 100644 --- a/generator/config/expression/setIntersection.yaml +++ b/generator/config/expression/setIntersection.yaml @@ -1,44 +1,37 @@ # $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 description: | Returns a set with elements that appear in all of the input sets. Accepts any number of argument expressions. arguments: - - - name: expression - type: - - resolvesToArray - variadic: array + - name: expression + type: + - resolvesToArray + variadic: array tests: - - - name: 'Elements Array Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/#elements-array-example' - pipeline: - - - $project: - flowerFieldA: 1 - flowerFieldB: 1 - commonToBoth: - $setIntersection: - - '$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' - pipeline: - - - $match: - $expr: - $not: + - name: Elements Array Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/#elements-array-example + pipeline: + - $project: + flowerFieldA: 1 + flowerFieldB: 1 + commonToBoth: + $setIntersection: + - $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 + 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' - - [] + - $eq: + - $setIntersection: + - $allowedRoles + - $$USER_ROLES.role + - [] diff --git a/generator/config/expression/setIsSubset.yaml b/generator/config/expression/setIsSubset.yaml index fe7c9ed02..5ecf9864e 100644 --- a/generator/config/expression/setIsSubset.yaml +++ b/generator/config/expression/setIsSubset.yaml @@ -1,32 +1,27 @@ # $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 description: | Returns true if all elements of the first set appear in the second set, including when the first set equals the second set; i.e. not a strict subset. Accepts exactly two argument expressions. arguments: - - - name: expression1 - type: - - resolvesToArray - - - name: expression2 - type: - - resolvesToArray + - name: expression1 + type: + - resolvesToArray + - name: expression2 + type: + - resolvesToArray tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIsSubset/#example' - pipeline: - - - $project: - flowerFieldA: 1 - flowerFieldB: 1 - AisSubset: - $setIsSubset: - - '$flowerFieldA' - - '$flowerFieldB' - _id: 0 - + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIsSubset/#example + pipeline: + - $project: + flowerFieldA: 1 + flowerFieldB: 1 + AisSubset: + $setIsSubset: + - $flowerFieldA + - $flowerFieldB + _id: 0 diff --git a/generator/config/expression/setUnion.yaml b/generator/config/expression/setUnion.yaml index 2cfca3e16..baa7895ee 100644 --- a/generator/config/expression/setUnion.yaml +++ b/generator/config/expression/setUnion.yaml @@ -1,28 +1,25 @@ # $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 description: | Returns a set with elements that appear in any of the input sets. arguments: - - - name: expression - type: - - resolvesToArray - variadic: array + - name: expression + type: + - resolvesToArray + variadic: array tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/#example' - pipeline: - - - $project: - flowerFieldA: 1 - flowerFieldB: 1 - allValues: - $setUnion: - - '$flowerFieldA' - - '$flowerFieldB' - _id: 0 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/#example + pipeline: + - $project: + flowerFieldA: 1 + flowerFieldB: 1 + allValues: + $setUnion: + - $flowerFieldA + - $flowerFieldB + _id: 0 diff --git a/generator/config/expression/sin.yaml b/generator/config/expression/sin.yaml index fe02b4f28..2e9a1e67c 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 @@ -8,23 +8,19 @@ encode: single description: | Returns the sine of a value that is measured in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $sin takes any valid expression that resolves to a number. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the result to radians. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $sin takes any valid expression that resolves to a number. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the result to radians. + 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' - pipeline: - - - $addFields: - side_b: - $multiply: - - - $sin: - $degreesToRadians: '$angle_a' - - '$hypotenuse' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sin/#example + pipeline: + - $addFields: + side_b: + $multiply: + - $sin: + $degreesToRadians: $angle_a + - $hypotenuse diff --git a/generator/config/expression/sinh.yaml b/generator/config/expression/sinh.yaml index a5b446add..2250b4f24 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 @@ -8,20 +8,17 @@ encode: single description: | Returns the hyperbolic sine of a value that is measured in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $sinh takes any valid expression that resolves to a number, measured in radians. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the value to radians. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $sinh takes any valid expression that resolves to a number, measured in radians. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the value to radians. + 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' - pipeline: - - - $addFields: - sinh_output: - $sinh: - $degreesToRadians: '$angle' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sinh/#example + pipeline: + - $addFields: + sinh_output: + $sinh: + $degreesToRadians: $angle diff --git a/generator/config/expression/size.yaml b/generator/config/expression/size.yaml index ce4fe775e..acd2dd7fa 100644 --- a/generator/config/expression/size.yaml +++ b/generator/config/expression/size.yaml @@ -1,33 +1,30 @@ # $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 description: | Returns the number of elements in the array. Accepts a single expression as argument. arguments: - - - name: expression - type: - - resolvesToArray - description: | - The argument for $size can be any expression as long as it resolves to an array. + - name: expression + type: + - resolvesToArray + description: | + 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' - pipeline: - - - $project: - item: 1 - numberOfColors: - $cond: - if: + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/size/#example + pipeline: + - $project: + item: 1 + numberOfColors: + $cond: + if: # Example uses the short form, the builder always generates the verbose form # $isArray: '$colors' - $isArray: - - '$colors' - then: - $size: '$colors' - else: 'NA' + $isArray: + - $colors + then: + $size: $colors + else: NA diff --git a/generator/config/expression/slice.yaml b/generator/config/expression/slice.yaml index 22cc287e1..a81534cf2 100644 --- a/generator/config/expression/slice.yaml +++ b/generator/config/expression/slice.yaml @@ -1,44 +1,39 @@ # $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 description: | Returns a subset of an array. arguments: - - - name: expression - type: - - resolvesToArray - description: | - Any valid expression as long as it resolves to an array. - - - name: position - type: - - resolvesToInt - optional: true - description: | - Any valid expression as long as it resolves to an integer. - 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" - type: - - resolvesToInt - description: | - Any valid expression as long as it resolves to an integer. If position is specified, n must resolve to a positive integer. - If positive, $slice returns up to the first n elements in the array. If the position is specified, $slice returns the first n elements starting from the position. - If negative, $slice returns up to the last n elements in the array. n cannot resolve to a negative number if is specified. + - name: expression + type: + - resolvesToArray + description: | + Any valid expression as long as it resolves to an array. + - name: position + type: + - resolvesToInt + optional: true + description: | + Any valid expression as long as it resolves to an integer. + 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 + type: + - resolvesToInt + description: | + Any valid expression as long as it resolves to an integer. If position is specified, n must resolve to a positive integer. + If positive, $slice returns up to the first n elements in the array. If the position is specified, $slice returns the first n elements starting from the position. + 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' - pipeline: - - - $project: - name: 1 - threeFavorites: - $slice: - - '$favorites' - - 3 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/slice/#example + pipeline: + - $project: + name: 1 + threeFavorites: + $slice: + - $favorites + - 3 diff --git a/generator/config/expression/sortArray.yaml b/generator/config/expression/sortArray.yaml index d558f2233..21727c536 100644 --- a/generator/config/expression/sortArray.yaml +++ b/generator/config/expression/sortArray.yaml @@ -1,108 +1,92 @@ # $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 description: | Sorts the elements of an array. arguments: - - - name: input - type: - - resolvesToArray - description: | - The array to be sorted. - The result is null if the expression: is missing, evaluates to null, or evaluates to undefined - If the expression evaluates to any other non-array value, the document returns an error. - - - name: sortBy - type: - - int - - sortSpec - - sortBy - description: | - The document specifies a sort ordering. + - name: input + type: + - resolvesToArray + description: | + The array to be sorted. + The result is null if the expression: is missing, evaluates to null, or evaluates to undefined + If the expression evaluates to any other non-array value, the document returns an error. + - name: sortBy + type: + - int + - sortSpec + - sortBy + description: | + 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' - pipeline: - - - $project: - _id: 0 - result: - $sortArray: - 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' - pipeline: - - - $project: - _id: 0 - result: - $sortArray: - 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' - pipeline: - - - $project: - _id: 0 - result: - $sortArray: - 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' - pipeline: - - - $project: - _id: 0 - result: - $sortArray: - input: - - 1 - - 4 - - 1 - - 6 - - 12 - - 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' - pipeline: - - - $project: - _id: 0 - result: - $sortArray: - input: - - 20 - - 4 - - - a: 'Free' - - 6 - - 21 - - 5 - - 'Gratis' - - - a: ~ - - - a: - sale: true - price: 19 - - !bson_decimal128 '10.23' - - - a: 'On sale' - sortBy: 1 + - 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 + sortBy: + name: 1 + - 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 + sortBy: + address.city: -1 + - 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 + 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 + pipeline: + - $project: + _id: 0 + result: + $sortArray: + input: + - 1 + - 4 + - 1 + - 6 + - 12 + - 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 + pipeline: + - $project: + _id: 0 + result: + $sortArray: + input: + - 20 + - 4 + - a: Free + - 6 + - 21 + - 5 + - Gratis + - a: ~ + - a: + sale: true + price: 19 + - !bson_decimal128 '10.23' + - a: On sale + sortBy: 1 diff --git a/generator/config/expression/split.yaml b/generator/config/expression/split.yaml index 1c6169910..7f9621be4 100644 --- a/generator/config/expression/split.yaml +++ b/generator/config/expression/split.yaml @@ -1,48 +1,40 @@ # $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 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. arguments: - - - name: string - type: - - resolvesToString - description: | - The string to be split. string expression can be any valid expression as long as it resolves to a string. - - - name: delimiter - type: - - resolvesToString - description: | - The delimiter to use when splitting the string expression. delimiter can be any valid expression as long as it resolves to a string. + - name: string + type: + - resolvesToString + description: | + The string to be split. string expression can be any valid expression as long as it resolves to a string. + - name: delimiter + type: + - resolvesToString + description: | + 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' - pipeline: - - - $project: - city_state: - $split: - - '$city' - - ', ' - qty: 1 - - - $unwind: - path: '$city_state' - - - $match: - city_state: !bson_regex '[A-Z]{2}' - - - $group: - _id: - state: '$city_state' - total_qty: - $sum: '$qty' - - - $sort: - total_qty: -1 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/split/#example + pipeline: + - $project: + city_state: + $split: + - $city + - ', ' + qty: 1 + - $unwind: + path: $city_state + - $match: + city_state: !bson_regex '[A-Z]{2}' + - $group: + _id: + state: $city_state + total_qty: + $sum: $qty + - $sort: + total_qty: -1 diff --git a/generator/config/expression/sqrt.yaml b/generator/config/expression/sqrt.yaml index 52f5bb7c2..57f0929e9 100644 --- a/generator/config/expression/sqrt.yaml +++ b/generator/config/expression/sqrt.yaml @@ -1,39 +1,32 @@ # $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 description: | Calculates the square root. arguments: - - - name: number - type: - - resolvesToNumber - description: | - The argument can be any valid expression as long as it resolves to a non-negative number. + - name: number + type: + - resolvesToNumber + description: | + 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' - pipeline: - - - $project: - distance: - $sqrt: - $add: - - - $pow: - - - $subtract: - - '$p2.y' - - '$p1.y' - - 2 - - - $pow: - - - $subtract: - - '$p2.x' - - '$p1.x' - - 2 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sqrt/#example + pipeline: + - $project: + distance: + $sqrt: + $add: + - $pow: + - $subtract: + - $p2.y + - $p1.y + - 2 + - $pow: + - $subtract: + - $p2.x + - $p1.x + - 2 diff --git a/generator/config/expression/stdDevPop.yaml b/generator/config/expression/stdDevPop.yaml index 46641ebe8..e525618d4 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 @@ -9,19 +9,17 @@ description: | If the values represent only a sample of a population of data from which to generalize about the population, use $stdDevSamp instead. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - resolvesToNumber - variadic: array + - name: expression + type: + - resolvesToNumber + variadic: array tests: - - - name: 'Use in $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/#use-in--project-stage' - pipeline: - - - $project: - stdDev: + - 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..0312074f2 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 @@ -8,8 +8,7 @@ description: | Calculates the sample standard deviation of the input values. Use if the values encompass a sample of a population of data from which to generalize about the population. $stdDevSamp ignores non-numeric values. If the values represent the entire population of data or you do not wish to generalize about a larger population, use $stdDevPop instead. arguments: - - - name: expression - type: - - resolvesToNumber - variadic: array + - name: expression + type: + - resolvesToNumber + variadic: array diff --git a/generator/config/expression/strLenBytes.yaml b/generator/config/expression/strLenBytes.yaml index 301150d19..a554a1797 100644 --- a/generator/config/expression/strLenBytes.yaml +++ b/generator/config/expression/strLenBytes.yaml @@ -1,23 +1,20 @@ # $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 description: | Returns the number of UTF-8 encoded bytes in a string. arguments: - - - name: expression - type: - - resolvesToString + - name: expression + type: + - 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' - pipeline: - - - $project: - name: 1 - length: - $strLenBytes: '$name' + - 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 diff --git a/generator/config/expression/strLenCP.yaml b/generator/config/expression/strLenCP.yaml index b852c80ec..0f11ebff7 100644 --- a/generator/config/expression/strLenCP.yaml +++ b/generator/config/expression/strLenCP.yaml @@ -1,23 +1,20 @@ # $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 description: | Returns the number of UTF-8 code points in a string. arguments: - - - name: expression - type: - - resolvesToString + - name: expression + type: + - 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' - pipeline: - - - $project: - name: 1 - length: - $strLenCP: '$name' + - 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 diff --git a/generator/config/expression/strcasecmp.yaml b/generator/config/expression/strcasecmp.yaml index 6775c44b1..fc2ef6980 100644 --- a/generator/config/expression/strcasecmp.yaml +++ b/generator/config/expression/strcasecmp.yaml @@ -1,29 +1,25 @@ # $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 description: | Performs case-insensitive string comparison and returns: 0 if two strings are equivalent, 1 if the first string is greater than the second, and -1 if the first string is less than the second. arguments: - - - name: expression1 - type: - - resolvesToString - - - name: expression2 - type: - - resolvesToString + - name: expression1 + type: + - resolvesToString + - name: expression2 + type: + - resolvesToString tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/strcasecmp/#example' - pipeline: - - - $project: - item: 1 - comparisonResult: - $strcasecmp: - - '$quarter' - - '13q4' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/strcasecmp/#example + pipeline: + - $project: + item: 1 + comparisonResult: + $strcasecmp: + - $quarter + - 13q4 diff --git a/generator/config/expression/substr.yaml b/generator/config/expression/substr.yaml index 6bcf6143f..a3d9c027a 100644 --- a/generator/config/expression/substr.yaml +++ b/generator/config/expression/substr.yaml @@ -1,43 +1,38 @@ # $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 description: | Deprecated. Use $substrBytes or $substrCP. arguments: - - - name: string - type: - - resolvesToString - - - name: start - type: - - resolvesToInt - description: | - If start is a negative number, $substr returns an empty string "". - - - name: length - type: - - resolvesToInt - description: | - If length is a negative number, $substr returns a substring that starts at the specified index and includes the rest of the string. + - name: string + type: + - resolvesToString + - name: start + type: + - resolvesToInt + description: | + If start is a negative number, $substr returns an empty string "". + - name: length + type: + - resolvesToInt + description: | + 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' - pipeline: - - - $project: - item: 1 - yearSubstring: - $substr: - - '$quarter' - - 0 - - 2 - quarterSubtring: - $substr: - - '$quarter' - - 2 - - -1 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/substr/#example + pipeline: + - $project: + item: 1 + yearSubstring: + $substr: + - $quarter + - 0 + - 2 + quarterSubtring: + $substr: + - $quarter + - 2 + - -1 diff --git a/generator/config/expression/substrBytes.yaml b/generator/config/expression/substrBytes.yaml index fed7677c8..4d9465f26 100644 --- a/generator/config/expression/substrBytes.yaml +++ b/generator/config/expression/substrBytes.yaml @@ -1,59 +1,50 @@ # $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 description: | Returns the substring of a string. Starts with the character at the specified UTF-8 byte index (zero-based) in the string and continues for the specified number of bytes. arguments: - - - name: string - type: - - resolvesToString - - - name: start - type: - - resolvesToInt - description: | - If start is a negative number, $substr returns an empty string "". - - - name: length - type: - - resolvesToInt - description: | - If length is a negative number, $substr returns a substring that starts at the specified index and includes the rest of the string. + - name: string + type: + - resolvesToString + - name: start + type: + - resolvesToInt + description: | + If start is a negative number, $substr returns an empty string "". + - name: length + type: + - resolvesToInt + description: | + 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' - pipeline: - - - $project: - item: 1 - yearSubstring: - $substrBytes: - - '$quarter' - - 0 - - 2 - quarterSubtring: - $substrBytes: - - '$quarter' - - 2 - - - $subtract: - - - $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' - pipeline: - - - $project: - name: 1 - menuCode: - $substrBytes: - - '$name' - - 0 - - 3 + - 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 + - 0 + - 2 + quarterSubtring: + $substrBytes: + - $quarter + - 2 + - $subtract: + - $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 + pipeline: + - $project: + name: 1 + menuCode: + $substrBytes: + - $name + - 0 + - 3 diff --git a/generator/config/expression/substrCP.yaml b/generator/config/expression/substrCP.yaml index 843b2ca1a..46369dd32 100644 --- a/generator/config/expression/substrCP.yaml +++ b/generator/config/expression/substrCP.yaml @@ -1,59 +1,50 @@ # $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 description: | Returns the substring of a string. Starts with the character at the specified UTF-8 code point (CP) index (zero-based) in the string and continues for the number of code points specified. arguments: - - - name: string - type: - - resolvesToString - - - name: start - type: - - resolvesToInt - description: | - If start is a negative number, $substr returns an empty string "". - - - name: length - type: - - resolvesToInt - description: | - If length is a negative number, $substr returns a substring that starts at the specified index and includes the rest of the string. + - name: string + type: + - resolvesToString + - name: start + type: + - resolvesToInt + description: | + If start is a negative number, $substr returns an empty string "". + - name: length + type: + - resolvesToInt + description: | + 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' - pipeline: - - - $project: - item: 1 - yearSubstring: - $substrCP: - - '$quarter' - - 0 - - 2 - quarterSubtring: - $substrCP: - - '$quarter' - - 2 - - - $subtract: - - - $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' - pipeline: - - - $project: - name: 1 - menuCode: - $substrCP: - - '$name' - - 0 - - 3 + - 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 + - 0 + - 2 + quarterSubtring: + $substrCP: + - $quarter + - 2 + - $subtract: + - $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 + pipeline: + - $project: + name: 1 + menuCode: + $substrCP: + - $name + - 0 + - 3 diff --git a/generator/config/expression/subtract.yaml b/generator/config/expression/subtract.yaml index b6db65ac9..eeb7ba4b9 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 @@ -11,50 +11,41 @@ encode: array description: | Returns the result of subtracting the second value from the first. If the two values are numbers, return the difference. If the two values are dates, return the difference in milliseconds. If the two values are a date and a number in milliseconds, return the resulting date. Accepts two argument expressions. If the two values are a date and a number, specify the date argument first as it is not meaningful to subtract a date from a number. arguments: - - - name: expression1 - type: - - resolvesToNumber - - resolvesToDate - - - name: expression2 - type: - - resolvesToNumber - - resolvesToDate + - name: expression1 + type: + - resolvesToNumber + - resolvesToDate + - name: expression2 + type: + - resolvesToNumber + - resolvesToDate tests: - - - name: 'Subtract Numbers' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#subtract-numbers' - pipeline: - - - $project: - item: 1 - total: - $subtract: - - - $add: - - '$price' - - '$fee' - - '$discount' - - - 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' - - - 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' - - 300000 + - name: Subtract Numbers + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#subtract-numbers + pipeline: + - $project: + item: 1 + total: + $subtract: + - $add: + - $price + - $fee + - $discount + - 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 + - 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 + - 300000 diff --git a/generator/config/expression/sum.yaml b/generator/config/expression/sum.yaml index 25b323ab1..6261d5a1e 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 @@ -8,29 +8,26 @@ description: | Returns a sum of numerical values. Ignores non-numeric values. Changed in MongoDB 5.0: Available in the $setWindowFields stage. arguments: - - - name: expression - type: - - resolvesToNumber - - resolvesToArray - variadic: array + - name: expression + type: + - resolvesToNumber + - resolvesToArray + variadic: array tests: - - - name: 'Use in $project Stage' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/#use-in--project-stage' - pipeline: - - - $project: - quizTotal: + - 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' - labTotal: + $sum: + - $quizzes + labTotal: # $sum: '$labs' - $sum: - - '$labs' - examTotal: - $sum: - - '$final' - - '$midterm' + $sum: + - $labs + examTotal: + $sum: + - $final + - $midterm diff --git a/generator/config/expression/switch.yaml b/generator/config/expression/switch.yaml index d668e3d94..9b4f9003a 100644 --- a/generator/config/expression/switch.yaml +++ b/generator/config/expression/switch.yaml @@ -1,70 +1,61 @@ # $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 description: | Evaluates a series of case expressions. When it finds an expression which evaluates to true, $switch executes a specified expression and breaks out of the control flow. arguments: - - - name: branches - type: - - array # of CaseOperator - 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. - - then Can be any valid expression. - The branches array must contain at least one branch document. - - - name: default - type: - - expression - optional: true - description: | - The path to take if no branch case expression evaluates to true. - Although optional, if default is unspecified and no branch case evaluates to true, $switch returns an error. + - name: branches + type: + - array # of CaseOperator + 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. + - then Can be any valid expression. + The branches array must contain at least one branch document. + - name: default + type: + - expression + optional: true + description: | + The path to take if no branch case expression evaluates to true. + 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' - pipeline: - - - $project: - name: 1 - summary: - $switch: - branches: - - - case: - $gte: - - + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/#example + pipeline: + - $project: + name: 1 + summary: + $switch: + branches: + - case: + $gte: #$avg: '$scores' - $avg: [ '$scores' ] - - 90 - then: 'Doing great!' - - - case: - $and: - - - $gte: - - + - $avg: + - $scores + - 90 + then: Doing great! + - case: + $and: + - $gte: #$avg: '$scores' - $avg: [ '$scores' ] - - 80 - - - $lt: - - + - $avg: + - $scores + - 80 + - $lt: #$avg: '$scores' - $avg: [ '$scores' ] - - 90 - then: 'Doing pretty well.' - - - case: - $lt: - - + - $avg: + - $scores + - 90 + then: Doing pretty well. + - case: + $lt: #$avg: '$scores' - $avg: [ '$scores' ] - - 80 - then: 'Needs improvement.' - default: 'No scores found.' + - $avg: + - $scores + - 80 + then: Needs improvement. + default: No scores found. diff --git a/generator/config/expression/tan.yaml b/generator/config/expression/tan.yaml index 17b11ee63..ed9977486 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 @@ -8,23 +8,19 @@ encode: single description: | Returns the tangent of a value that is measured in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $tan takes any valid expression that resolves to a number. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the result to radians. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $tan takes any valid expression that resolves to a number. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the result to radians. + 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' - pipeline: - - - $addFields: - side_b: - $multiply: - - - $tan: - $degreesToRadians: '$angle_a' - - '$side_a' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tan/#example + pipeline: + - $addFields: + side_b: + $multiply: + - $tan: + $degreesToRadians: $angle_a + - $side_a diff --git a/generator/config/expression/tanh.yaml b/generator/config/expression/tanh.yaml index 364589452..71d79ab07 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 @@ -8,20 +8,17 @@ encode: single description: | Returns the hyperbolic tangent of a value that is measured in radians. arguments: - - - name: expression - type: - - resolvesToNumber - description: | - $tanh takes any valid expression that resolves to a number, measured in radians. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the value to radians. - 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. + - name: expression + type: + - resolvesToNumber + description: | + $tanh takes any valid expression that resolves to a number, measured in radians. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the value to radians. + 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' - pipeline: - - - $addFields: - tanh_output: - $tanh: - $degreesToRadians: '$angle' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/tanh/#example + pipeline: + - $addFields: + tanh_output: + $tanh: + $degreesToRadians: $angle diff --git a/generator/config/expression/toBool.yaml b/generator/config/expression/toBool.yaml index 7f771ec8d..e1756ca9d 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 @@ -8,34 +8,28 @@ description: | Converts value to a boolean. New in MongoDB 4.0. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toBool/#example' - pipeline: - - - $addFields: - convertedShippedFlag: - $switch: - branches: - - - case: - $eq: - - '$shipped' - - 'false' - then: false - - - case: - $eq: - - '$shipped' - - '' - then: false - default: - $toBool: '$shipped' - - - $match: - convertedShippedFlag: false + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toBool/#example + pipeline: + - $addFields: + convertedShippedFlag: + $switch: + branches: + - case: + $eq: + - $shipped + - 'false' + then: false + - case: + $eq: + - $shipped + - '' + then: false + default: + $toBool: $shipped + - $match: + convertedShippedFlag: false diff --git a/generator/config/expression/toDate.yaml b/generator/config/expression/toDate.yaml index d9434a6bd..626cdd34a 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 @@ -8,19 +8,15 @@ description: | Converts value to a Date. New in MongoDB 4.0. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/#example' - pipeline: - - - $addFields: - convertedDate: - $toDate: '$order_date' - - - $sort: - convertedDate: 1 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/#example + pipeline: + - $addFields: + convertedDate: + $toDate: $order_date + - $sort: + convertedDate: 1 diff --git a/generator/config/expression/toDecimal.yaml b/generator/config/expression/toDecimal.yaml index 2f3588323..6735f3516 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 @@ -8,16 +8,13 @@ description: | Converts value to a Decimal128. New in MongoDB 4.0. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDecimal/#example' - pipeline: - - - $addFields: - convertedPrice: - $toDecimal: '$price' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDecimal/#example + pipeline: + - $addFields: + convertedPrice: + $toDecimal: $price diff --git a/generator/config/expression/toDouble.yaml b/generator/config/expression/toDouble.yaml index f34c36e9a..93fc569cb 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 @@ -8,20 +8,17 @@ description: | Converts value to a double. New in MongoDB 4.0. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDouble/#example' - pipeline: - - - $addFields: - degrees: - $toDouble: - $substrBytes: - - '$temp' - - 0 - - 4 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDouble/#example + pipeline: + - $addFields: + degrees: + $toDouble: + $substrBytes: + - $temp + - 0 + - 4 diff --git a/generator/config/expression/toHashedIndexKey.yaml b/generator/config/expression/toHashedIndexKey.yaml index f5811f56d..a6b556662 100644 --- a/generator/config/expression/toHashedIndexKey.yaml +++ b/generator/config/expression/toHashedIndexKey.yaml @@ -1,28 +1,23 @@ # $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..d8b1cf113 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 @@ -8,16 +8,13 @@ description: | Converts value to an integer. New in MongoDB 4.0. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/#example' - pipeline: - - - $addFields: - convertedQty: - $toInt: '$qty' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/#example + pipeline: + - $addFields: + convertedQty: + $toInt: $qty diff --git a/generator/config/expression/toLong.yaml b/generator/config/expression/toLong.yaml index 3168ad9ff..c78cdebf1 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 @@ -8,19 +8,15 @@ description: | Converts value to a long. New in MongoDB 4.0. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/#example' - pipeline: - - - $addFields: - convertedQty: - $toLong: '$qty' - - - $sort: - convertedQty: -1 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/#example + pipeline: + - $addFields: + convertedQty: + $toLong: $qty + - $sort: + convertedQty: -1 diff --git a/generator/config/expression/toLower.yaml b/generator/config/expression/toLower.yaml index 0d6176672..349073e8e 100644 --- a/generator/config/expression/toLower.yaml +++ b/generator/config/expression/toLower.yaml @@ -1,24 +1,21 @@ # $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 description: | Converts a string to lowercase. Accepts a single argument expression. arguments: - - - name: expression - type: - - resolvesToString + - name: expression + type: + - resolvesToString tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLower/#example' - pipeline: - - - $project: - item: - $toLower: '$item' - description: - $toLower: '$description' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLower/#example + pipeline: + - $project: + item: + $toLower: $item + description: + $toLower: $description diff --git a/generator/config/expression/toObjectId.yaml b/generator/config/expression/toObjectId.yaml index 803f7cafa..54f696346 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 @@ -8,19 +8,15 @@ description: | Converts value to an ObjectId. New in MongoDB 4.0. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObjectId/#example' - pipeline: - - - $addFields: - convertedId: - $toObjectId: '$_id' - - - $sort: - convertedId: -1 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObjectId/#example + pipeline: + - $addFields: + convertedId: + $toObjectId: $_id + - $sort: + convertedId: -1 diff --git a/generator/config/expression/toString.yaml b/generator/config/expression/toString.yaml index 0fd068562..f58d27789 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 @@ -8,19 +8,15 @@ description: | Converts value to a string. New in MongoDB 4.0. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/#example' - pipeline: - - - $addFields: - convertedZipCode: - $toString: '$zipcode' - - - $sort: - convertedZipCode: 1 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/#example + pipeline: + - $addFields: + convertedZipCode: + $toString: $zipcode + - $sort: + convertedZipCode: 1 diff --git a/generator/config/expression/toUpper.yaml b/generator/config/expression/toUpper.yaml index c2c71e1bc..a36cc1263 100644 --- a/generator/config/expression/toUpper.yaml +++ b/generator/config/expression/toUpper.yaml @@ -1,24 +1,21 @@ # $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 description: | Converts a string to uppercase. Accepts a single argument expression. arguments: - - - name: expression - type: - - resolvesToString + - name: expression + type: + - resolvesToString tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUpper/#example' - pipeline: - - - $project: - item: - $toUpper: '$item' - description: - $toUpper: '$description' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUpper/#example + pipeline: + - $project: + item: + $toUpper: $item + description: + $toUpper: $description diff --git a/generator/config/expression/trim.yaml b/generator/config/expression/trim.yaml index d63423910..929d5233c 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 @@ -8,29 +8,25 @@ description: | Removes whitespace or the specified characters from the beginning and end of a string. New in MongoDB 4.0. arguments: - - - name: input - type: - - resolvesToString - description: | - The string to trim. The argument can be any valid expression that resolves to a string. - - - name: chars - type: - - resolvesToString - optional: true - description: | - The character(s) to trim from the beginning of the input. - The argument can be any valid expression that resolves to a string. The $ltrim operator breaks down the string into individual UTF code point to trim from input. - If unspecified, $ltrim removes whitespace characters, including the null character. + - name: input + type: + - resolvesToString + description: | + The string to trim. The argument can be any valid expression that resolves to a string. + - name: chars + type: + - resolvesToString + optional: true + description: | + The character(s) to trim from the beginning of the input. + The argument can be any valid expression that resolves to a string. The $ltrim operator breaks down the string into individual UTF code point to trim from input. + 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' - pipeline: - - - $project: - item: 1 - description: - $trim: - input: '$description' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/trim/#example + pipeline: + - $project: + item: 1 + description: + $trim: + input: $description diff --git a/generator/config/expression/trunc.yaml b/generator/config/expression/trunc.yaml index f930cf027..bb458d4f5 100644 --- a/generator/config/expression/trunc.yaml +++ b/generator/config/expression/trunc.yaml @@ -1,34 +1,30 @@ # $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 description: | Truncates a number to a whole integer or to a specified decimal place. arguments: - - - name: number - type: - - resolvesToNumber - description: | - Can be any valid expression that resolves to a number. Specifically, the expression must resolve to an integer, double, decimal, or long. - $trunc returns an error if the expression resolves to a non-numeric data type. - - - name: place - type: - - resolvesToInt - optional: true - description: | - Can be any valid expression that resolves to an integer between -20 and 100, exclusive. e.g. -20 < place < 100. Defaults to 0. + - name: number + type: + - resolvesToNumber + description: | + Can be any valid expression that resolves to a number. Specifically, the expression must resolve to an integer, double, decimal, or long. + $trunc returns an error if the expression resolves to a non-numeric data type. + - name: place + type: + - resolvesToInt + optional: true + description: | + 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' - pipeline: - - - $project: - truncatedValue: - $trunc: - - '$value' - - 1 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/#example + pipeline: + - $project: + truncatedValue: + $trunc: + - $value + - 1 diff --git a/generator/config/expression/tsIncrement.yaml b/generator/config/expression/tsIncrement.yaml index 9fded2143..28a9dae2f 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 @@ -8,32 +8,25 @@ description: | Returns the incrementing ordinal from a timestamp as a long. New in MongoDB 5.1. arguments: - - - name: expression - type: - - resolvesToTimestamp + - name: expression + type: + - 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' - pipeline: - - - $project: - _id: 0 - saleTimestamp: 1 - saleIncrement: - $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' - pipeline: - - - $match: - $expr: - $eq: - - - $mod: - - - $tsIncrement: '$clusterTime' - - 2 - - 0 + - 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 + - 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: + $expr: + $eq: + - $mod: + - $tsIncrement: $clusterTime + - 2 + - 0 diff --git a/generator/config/expression/tsSecond.yaml b/generator/config/expression/tsSecond.yaml index 20a84904b..436858368 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 @@ -8,26 +8,21 @@ description: | Returns the seconds from a timestamp as a long. New in MongoDB 5.1. arguments: - - - name: expression - type: - - resolvesToTimestamp + - name: expression + type: + - 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' - pipeline: - - - $project: - _id: 0 - saleTimestamp: 1 - saleSeconds: - $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' - pipeline: - - - $addFields: - clusterTimeSeconds: - $tsSecond: '$clusterTime' + - 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 + - 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 diff --git a/generator/config/expression/type.yaml b/generator/config/expression/type.yaml index c1f63db79..2c210c47a 100644 --- a/generator/config/expression/type.yaml +++ b/generator/config/expression/type.yaml @@ -1,22 +1,19 @@ # $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 description: | Return the BSON data type of the field. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/type/#example' - pipeline: - - - $project: - a: - $type: '$a' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/type/#example + pipeline: + - $project: + a: + $type: $a diff --git a/generator/config/expression/unsetField.yaml b/generator/config/expression/unsetField.yaml index a4365a646..3b5633f9c 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 @@ -8,52 +8,44 @@ description: | You can use $unsetField to remove fields with names that contain periods (.) or that start with dollar signs ($). $unsetField is an alias for $setField using $$REMOVE to remove fields. arguments: - - - name: field - type: - - resolvesToString - description: | - Field in the input object that you want to add, update, or remove. field can be any valid expression that resolves to a string constant. - - - name: input - type: - - resolvesToObject - description: | - Document that contains the field that you want to add or update. input must resolve to an object, missing, null, or undefined. + - name: field + type: + - resolvesToString + description: | + Field in the input object that you want to add, update, or remove. field can be any valid expression that resolves to a string constant. + - name: input + type: + - resolvesToObject + description: | + 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--.-' - pipeline: - - - $replaceWith: - $unsetField: - 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----' - pipeline: - - - $replaceWith: - $unsetField: - field: - $literal: '$price' - input: '$$ROOT' - - - 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' - value: - $unsetField: - field: 'euro' - input: + - 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 + - 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 + - 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 + value: + $unsetField: + field: euro + input: # Example uses the short form, the builder always generates the verbose form # $getField: 'price' - $getField: - field: 'price' + $getField: + field: price diff --git a/generator/config/expression/week.yaml b/generator/config/expression/week.yaml index 6086f57ee..ebfeb0dcb 100644 --- a/generator/config/expression/week.yaml +++ b/generator/config/expression/week.yaml @@ -1,36 +1,32 @@ # $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 description: | Returns the week number for a date as a number between 0 (the partial week that precedes the first Sunday of the year) and 53 (leap year). arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - week: + - 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' + $week: + date: $date diff --git a/generator/config/expression/year.yaml b/generator/config/expression/year.yaml index 3326e3495..6b3babbf2 100644 --- a/generator/config/expression/year.yaml +++ b/generator/config/expression/year.yaml @@ -1,36 +1,32 @@ # $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 description: | Returns the year for a date as a number (e.g. 2014). arguments: - - - name: date - type: - - resolvesToDate - - resolvesToTimestamp - - resolvesToObjectId - description: | - The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. - - - name: timezone - type: - - resolvesToString - optional: true - description: | - 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. + - name: date + type: + - resolvesToDate + - resolvesToTimestamp + - resolvesToObjectId + description: | + The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. + - name: timezone + type: + - resolvesToString + optional: true + description: | + 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' - pipeline: - - - $project: - year: + - 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' + $year: + date: $date diff --git a/generator/config/expression/zip.yaml b/generator/config/expression/zip.yaml index 76402dac5..f9e99e5ef 100644 --- a/generator/config/expression/zip.yaml +++ b/generator/config/expression/zip.yaml @@ -1,87 +1,75 @@ # $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 encode: object description: | Merge two arrays together. arguments: - - - name: inputs - type: - - resolvesToArray # of array - 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. - If any of the inputs arrays does not resolve to an array or null nor refers to a missing field, $zip returns an error. - - - name: useLongestLength - type: - - bool - optional: true - description: | - A boolean which specifies whether the length of the longest array determines the number of arrays in the output array. - The default value is false: the shortest array length determines the number of arrays in the output array. - - - name: defaults - type: - - array - optional: true - description: | - An array of default element values to use if the input arrays have different lengths. You must specify useLongestLength: true along with this field, or else $zip will return an error. - If useLongestLength: true but defaults is empty or not specified, $zip uses null as the default value. - If specifying a non-empty defaults, you must specify a default for each input array or else $zip will return an error. + - name: inputs + type: + - resolvesToArray # of array + 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. + If any of the inputs arrays does not resolve to an array or null nor refers to a missing field, $zip returns an error. + - name: useLongestLength + type: + - bool + optional: true + description: | + A boolean which specifies whether the length of the longest array determines the number of arrays in the output array. + The default value is false: the shortest array length determines the number of arrays in the output array. + - name: defaults + type: + - array + optional: true + description: | + An array of default element values to use if the input arrays have different lengths. You must specify useLongestLength: true along with this field, or else $zip will return an error. + If useLongestLength: true but defaults is empty or not specified, $zip uses null as the default value. + 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' - pipeline: - - - $project: - _id: false - transposed: - $zip: - inputs: - - - $arrayElemAt: - - '$matrix' - - 0 - - - $arrayElemAt: - - '$matrix' + - name: Matrix Transposition + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/#matrix-transposition + pipeline: + - $project: + _id: false + transposed: + $zip: + inputs: + - $arrayElemAt: + - $matrix + - 0 + - $arrayElemAt: + - $matrix + - 1 + - $arrayElemAt: + - $matrix + - 2 + - name: Filtering and Preserving Indexes + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/#filtering-and-preserving-indexes + pipeline: + - $project: + _id: false + pages: + $filter: + input: + $zip: + inputs: + - $pages + - $range: + - 0 + - $size: $pages + as: pageWithIndex + cond: + $let: + vars: + page: + $arrayElemAt: + - $$pageWithIndex + - 0 + in: + $gte: + - $$page.reviews - 1 - - - $arrayElemAt: - - '$matrix' - - 2 - - - name: 'Filtering and Preserving Indexes' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/#filtering-and-preserving-indexes' - pipeline: - - - $project: - _id: false - pages: - $filter: - input: - $zip: - inputs: - - '$pages' - - - $range: - - 0 - - - $size: '$pages' - as: 'pageWithIndex' - cond: - $let: - vars: - page: - $arrayElemAt: - - '$$pageWithIndex' - - 0 - in: - $gte: - - '$$page.reviews' - - 1 diff --git a/generator/config/query/all.yaml b/generator/config/query/all.yaml index 868e205e2..8dbea6384 100644 --- a/generator/config/query/all.yaml +++ b/generator/config/query/all.yaml @@ -1,43 +1,36 @@ # $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 description: | Matches arrays that contain all elements specified in the query. arguments: - - - name: value - type: - - fieldQuery - variadic: array + - name: value + type: + - fieldQuery + 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' - pipeline: - - - $match: - tags: - $all: - - 'appliance' - - 'school' - - 'book' - - - name: 'Use $all with $elemMatch' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/all/#use--all-with--elemmatch' - pipeline: - - - $match: - qty: - $all: - - - $elemMatch: - size: 'M' - num: - $gt: 50 - - - $elemMatch: - num: 100 - color: 'green' + - 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 + - name: Use $all with $elemMatch + link: https://www.mongodb.com/docs/manual/reference/operator/query/all/#use--all-with--elemmatch + pipeline: + - $match: + qty: + $all: + - $elemMatch: + size: M + num: + $gt: 50 + - $elemMatch: + num: 100 + color: green diff --git a/generator/config/query/and.yaml b/generator/config/query/and.yaml index 74ebf506e..22cf3a143 100644 --- a/generator/config/query/and.yaml +++ b/generator/config/query/and.yaml @@ -1,51 +1,38 @@ # $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 description: | Joins query clauses with a logical AND returns all documents that match the conditions of both clauses. arguments: - - - name: queries - type: - - query - variadic: array - variadicMin: 1 + - name: queries + type: + - query + variadic: array + 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' - pipeline: - - - $match: - $and: - - - price: - $ne: 1.99 - - - 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' - pipeline: - - - $match: - $and: - - - $or: - - - qty: - $lt: 10 - - - qty: - $gt: 50 - - - $or: - - - sale: true - - - price: - $lt: 5 + - 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: + $and: + - price: + $ne: 1.99 + - 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 + pipeline: + - $match: + $and: + - $or: + - qty: + $lt: 10 + - qty: + $gt: 50 + - $or: + - sale: true + - price: + $lt: 5 diff --git a/generator/config/query/bitsAllClear.yaml b/generator/config/query/bitsAllClear.yaml index 48e98037d..37061b97f 100644 --- a/generator/config/query/bitsAllClear.yaml +++ b/generator/config/query/bitsAllClear.yaml @@ -1,38 +1,35 @@ # $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 description: | Matches numeric or binary values in which a set of bit positions all have a value of 0. arguments: - - - name: bitmask - type: - - int - - binData - - array # of int + - name: bitmask + type: + - int + - binData + - array # of int tests: - - - name: 'Bit Position Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#bit-position-array' - pipeline: - - - $match: - a: - $bitsAllClear: [1, 5] - - - name: 'Integer Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#integer-bitmask' - pipeline: - - $match: - a: - $bitsAllClear: 35 - - - name: 'BinData Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#bindata-bitmask' - pipeline: - - $match: - a: - $bitsAllClear: !bson_binary 'IA==' + - name: Bit Position Array + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#bit-position-array + pipeline: + - $match: + a: + $bitsAllClear: + - 1 + - 5 + - name: Integer Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#integer-bitmask + pipeline: + - $match: + a: + $bitsAllClear: 35 + - name: BinData Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#bindata-bitmask + pipeline: + - $match: + a: + $bitsAllClear: !bson_binary 'IA==' diff --git a/generator/config/query/bitsAllSet.yaml b/generator/config/query/bitsAllSet.yaml index 25e2c6eb8..c02ffbfd9 100644 --- a/generator/config/query/bitsAllSet.yaml +++ b/generator/config/query/bitsAllSet.yaml @@ -1,38 +1,35 @@ # $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 description: | Matches numeric or binary values in which a set of bit positions all have a value of 1. arguments: - - - name: bitmask - type: - - int - - binData - - array # of int + - name: bitmask + type: + - int + - binData + - array # of int tests: - - - name: 'Bit Position Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#bit-position-array' - pipeline: - - - $match: - a: - $bitsAllSet: [1, 5] - - - name: 'Integer Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#integer-bitmask' - pipeline: - - $match: - a: - $bitsAllSet: 50 - - - name: 'BinData Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#bindata-bitmask' - pipeline: - - $match: - a: - $bitsAllSet: !bson_binary 'MA==' + - name: Bit Position Array + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#bit-position-array + pipeline: + - $match: + a: + $bitsAllSet: + - 1 + - 5 + - name: Integer Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#integer-bitmask + pipeline: + - $match: + a: + $bitsAllSet: 50 + - name: BinData Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#bindata-bitmask + pipeline: + - $match: + a: + $bitsAllSet: !bson_binary 'MA==' diff --git a/generator/config/query/bitsAnyClear.yaml b/generator/config/query/bitsAnyClear.yaml index a41260998..d0c75345a 100644 --- a/generator/config/query/bitsAnyClear.yaml +++ b/generator/config/query/bitsAnyClear.yaml @@ -1,38 +1,35 @@ # $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 description: | Matches numeric or binary values in which any bit from a set of bit positions has a value of 0. arguments: - - - name: bitmask - type: - - int - - binData - - array # of int + - name: bitmask + type: + - int + - binData + - array # of int tests: - - - name: 'Bit Position Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#bit-position-array' - pipeline: - - - $match: - a: - $bitsAnyClear: [1, 5] - - - name: 'Integer Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#integer-bitmask' - pipeline: - - $match: - a: - $bitsAnyClear: 35 - - - name: 'BinData Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#bindata-bitmask' - pipeline: - - $match: - a: - $bitsAnyClear: !bson_binary 'MA==' + - name: Bit Position Array + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#bit-position-array + pipeline: + - $match: + a: + $bitsAnyClear: + - 1 + - 5 + - name: Integer Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#integer-bitmask + pipeline: + - $match: + a: + $bitsAnyClear: 35 + - name: BinData Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#bindata-bitmask + pipeline: + - $match: + a: + $bitsAnyClear: !bson_binary 'MA==' diff --git a/generator/config/query/bitsAnySet.yaml b/generator/config/query/bitsAnySet.yaml index 95aae908a..53f54c39f 100644 --- a/generator/config/query/bitsAnySet.yaml +++ b/generator/config/query/bitsAnySet.yaml @@ -1,38 +1,35 @@ # $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 description: | Matches numeric or binary values in which any bit from a set of bit positions has a value of 1. arguments: - - - name: bitmask - type: - - int - - binData - - array # of int + - name: bitmask + type: + - int + - binData + - array # of int tests: - - - name: 'Bit Position Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#bit-position-array' - pipeline: - - - $match: - a: - $bitsAnySet: [1, 5] - - - name: 'Integer Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#integer-bitmask' - pipeline: - - $match: - a: - $bitsAnySet: 35 - - - name: 'BinData Bitmask' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#bindata-bitmask' - pipeline: - - $match: - a: - $bitsAnySet: !bson_binary 'MA==' + - name: Bit Position Array + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#bit-position-array + pipeline: + - $match: + a: + $bitsAnySet: + - 1 + - 5 + - name: Integer Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#integer-bitmask + pipeline: + - $match: + a: + $bitsAnySet: 35 + - name: BinData Bitmask + link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#bindata-bitmask + pipeline: + - $match: + a: + $bitsAnySet: !bson_binary 'MA==' diff --git a/generator/config/query/box.yaml b/generator/config/query/box.yaml index 14043c4ae..66091fb09 100644 --- a/generator/config/query/box.yaml +++ b/generator/config/query/box.yaml @@ -1,13 +1,12 @@ # $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 description: | Specifies a rectangular box using legacy coordinate pairs for $geoWithin queries. The 2d index supports $box. arguments: - - - name: value - type: - - array + - name: value + type: + - array diff --git a/generator/config/query/center.yaml b/generator/config/query/center.yaml index c86215a52..38c86aae5 100644 --- a/generator/config/query/center.yaml +++ b/generator/config/query/center.yaml @@ -1,13 +1,12 @@ # $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 description: | Specifies a circle using legacy coordinate pairs to $geoWithin queries when using planar geometry. The 2d index supports $center. arguments: - - - name: value - type: - - array + - name: value + type: + - array diff --git a/generator/config/query/centerSphere.yaml b/generator/config/query/centerSphere.yaml index e3677dade..47ead5c66 100644 --- a/generator/config/query/centerSphere.yaml +++ b/generator/config/query/centerSphere.yaml @@ -1,13 +1,12 @@ # $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 description: | Specifies a circle using either legacy coordinate pairs or GeoJSON format for $geoWithin queries when using spherical geometry. The 2dsphere and 2d indexes support $centerSphere. arguments: - - - name: value - type: - - array + - name: value + type: + - array diff --git a/generator/config/query/comment.yaml b/generator/config/query/comment.yaml index 13a344613..54f04bed8 100644 --- a/generator/config/query/comment.yaml +++ b/generator/config/query/comment.yaml @@ -1,31 +1,27 @@ # $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 description: | Adds a comment to a query predicate. arguments: - - - name: comment - type: - - string + - name: comment + type: + - 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' - pipeline: - - - $match: - x: - $gt: 0 - $comment: 'Don''t allow negative inputs.' - - - $group: - _id: - $mod: - - '$x' - - 2 - total: - $sum: '$x' + - 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. + - $group: + _id: + $mod: + - $x + - 2 + total: + $sum: $x diff --git a/generator/config/query/elemMatch.yaml b/generator/config/query/elemMatch.yaml index 95db9572e..f2ecbbe8e 100644 --- a/generator/config/query/elemMatch.yaml +++ b/generator/config/query/elemMatch.yaml @@ -1,68 +1,55 @@ # $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 description: | The $elemMatch operator matches documents that contain an array field with at least one element that matches all the specified query criteria. arguments: - - - name: query - type: - - query - - fieldQuery + - name: query + type: + - query + - fieldQuery tests: - - - name: 'Element Match' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/#element-match' - pipeline: - - - $match: - results: - $elemMatch: - $gte: 80 - $lt: 85 - - - 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' - score: - $gte: 8 - - - 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' - - - name: 'Using $or with $elemMatch' - pipeline: - - - $match: - game: - $elemMatch: - $or: - - - score: - $gt: 10 - - - score: - $lt: 5 - - - name: 'Single field operator' - pipeline: - - - $match: - results: - $elemMatch: - $gt: 10 + - name: Element Match + link: https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/#element-match + pipeline: + - $match: + results: + $elemMatch: + $gte: 80 + $lt: 85 + - 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 + score: + $gte: 8 + - 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 + - name: Using $or with $elemMatch + pipeline: + - $match: + game: + $elemMatch: + $or: + - score: + $gt: 10 + - score: + $lt: 5 + - name: Single field operator + pipeline: + - $match: + results: + $elemMatch: + $gt: 10 diff --git a/generator/config/query/eq.yaml b/generator/config/query/eq.yaml index 5629114cc..c5938e58c 100644 --- a/generator/config/query/eq.yaml +++ b/generator/config/query/eq.yaml @@ -1,61 +1,46 @@ # $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 description: | Matches values that are equal to a specified value. arguments: - - - name: value - type: - - any + - name: value + type: + - any tests: - - - 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' - pipeline: - - - $match: - 'item.name': - $eq: 'ab' - - - - 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'] - - - - name: 'Regex Match Behaviour' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/eq/#regex-match-behaviour' - pipeline: - - - $match: - company: 'MongoDB' - - - $match: - company: - $eq: 'MongoDB' - - - $match: - company: - !bson_regex '^MongoDB' - - - $match: - company: - $eq: - !bson_regex '^MongoDB' + - 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 + pipeline: + - $match: + item.name: + $eq: ab + - 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 + - name: Regex Match Behaviour + link: https://www.mongodb.com/docs/manual/reference/operator/query/eq/#regex-match-behaviour + pipeline: + - $match: + company: MongoDB + - $match: + company: + $eq: MongoDB + - $match: + company: !bson_regex '^MongoDB' + - $match: + company: + $eq: !bson_regex '^MongoDB' diff --git a/generator/config/query/exists.yaml b/generator/config/query/exists.yaml index 00d7ce2cb..a05958a3f 100644 --- a/generator/config/query/exists.yaml +++ b/generator/config/query/exists.yaml @@ -1,39 +1,34 @@ # $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 description: | Matches documents that have the specified field. arguments: - - - name: exists - type: - - bool - default: true + - name: exists + type: + - bool + 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' - pipeline: - - - $match: - qty: - $exists: true - $nin: [5, 15] - - - name: 'Null Values' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/exists/#null-values' - pipeline: - - - $match: - qty: - $exists: true - - - name: 'Missing Field' - pipeline: - - - $match: - qty: - $exists: false + - 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 + - name: Null Values + link: https://www.mongodb.com/docs/manual/reference/operator/query/exists/#null-values + pipeline: + - $match: + qty: + $exists: true + - name: Missing Field + pipeline: + - $match: + qty: + $exists: false diff --git a/generator/config/query/expr.yaml b/generator/config/query/expr.yaml index 320c84507..57e68bc85 100644 --- a/generator/config/query/expr.yaml +++ b/generator/config/query/expr.yaml @@ -1,47 +1,41 @@ # $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 description: | Allows use of aggregation expressions within the query language. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - 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' - pipeline: - - - $match: - $expr: - $gt: - - '$spent' - - '$budget' - - - name: 'Using $expr With Conditional Statements' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/expr/#using--expr-with-conditional-statements' - pipeline: - - - $match: - $expr: - $lt: - - - $cond: - if: - $gte: - - '$qty' - - 100 - then: - $multiply: - - '$price' - - 0.5 - else: - $multiply: - - '$price' - - 0.75 - - 5 + - 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 + - name: Using $expr With Conditional Statements + link: https://www.mongodb.com/docs/manual/reference/operator/query/expr/#using--expr-with-conditional-statements + pipeline: + - $match: + $expr: + $lt: + - $cond: + if: + $gte: + - $qty + - 100 + then: + $multiply: + - $price + - 0.5 + else: + $multiply: + - $price + - 0.75 + - 5 diff --git a/generator/config/query/geoIntersects.yaml b/generator/config/query/geoIntersects.yaml index 4df3a43de..0b540be8d 100644 --- a/generator/config/query/geoIntersects.yaml +++ b/generator/config/query/geoIntersects.yaml @@ -1,53 +1,46 @@ # $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 description: | Selects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects. arguments: - - - name: geometry - mergeObject: true - type: - - geometry + - name: geometry + mergeObject: true + type: + - geometry tests: - - - 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' - coordinates: - - - - [ 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' - pipeline: - - - $match: - loc: - $geoIntersects: - $geometry: - type: 'Polygon' - coordinates: - - - - [ -100, 60 ] - - [ -100, 0 ] - - [ -100, -60 ] - - [ 100, -60 ] - - [ 100, 60 ] - - [ -100, 60 ] - crs: - type: 'name' - properties: - name: 'urn:x-mongodb:crs:strictwinding:EPSG:4326' + - 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 + coordinates: + - - [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 + pipeline: + - $match: + loc: + $geoIntersects: + $geometry: + type: Polygon + coordinates: + - - [-100, 60] + - [-100, 0] + - [-100, -60] + - [100, -60] + - [100, 60] + - [-100, 60] + crs: + type: name + properties: + name: urn:x-mongodb:crs:strictwinding:EPSG:4326 diff --git a/generator/config/query/geoWithin.yaml b/generator/config/query/geoWithin.yaml index f9f6204d0..0cb439962 100644 --- a/generator/config/query/geoWithin.yaml +++ b/generator/config/query/geoWithin.yaml @@ -1,53 +1,46 @@ # $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 description: | Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin. arguments: - - - name: geometry - mergeObject: true - type: - - geometry + - name: geometry + mergeObject: true + type: + - geometry tests: - - - 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' - coordinates: - - - - [ 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' - pipeline: - - - $match: - loc: - $geoWithin: - $geometry: - type: 'Polygon' - coordinates: - - - - [ -100, 60 ] - - [ -100, 0 ] - - [ -100, -60 ] - - [ 100, -60 ] - - [ 100, 60 ] - - [ -100, 60 ] - crs: - type: 'name' - properties: - name: 'urn:x-mongodb:crs:strictwinding:EPSG:4326' + - 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 + coordinates: + - - [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 + pipeline: + - $match: + loc: + $geoWithin: + $geometry: + type: Polygon + coordinates: + - - [-100, 60] + - [-100, 0] + - [-100, -60] + - [100, -60] + - [100, 60] + - [-100, 60] + crs: + type: name + properties: + name: urn:x-mongodb:crs:strictwinding:EPSG:4326 diff --git a/generator/config/query/geometry.yaml b/generator/config/query/geometry.yaml index 40b18dc99..90190f3cc 100644 --- a/generator/config/query/geometry.yaml +++ b/generator/config/query/geometry.yaml @@ -1,22 +1,19 @@ # $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 description: | Specifies a geometry in GeoJSON format to geospatial query operators. arguments: - - - name: type - type: - - string - - - name: coordinates - type: - - array - - - name: crs - type: - - object - optional: true + - name: type + type: + - string + - name: coordinates + type: + - array + - name: crs + type: + - object + optional: true diff --git a/generator/config/query/gt.yaml b/generator/config/query/gt.yaml index 9914a5f34..5678ac953 100644 --- a/generator/config/query/gt.yaml +++ b/generator/config/query/gt.yaml @@ -1,22 +1,19 @@ # $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 description: | Matches values that are greater than a specified value. arguments: - - - name: value - type: - - any + - name: value + type: + - any tests: - - - name: 'Match Document Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/gt/#match-document-fields' - pipeline: - - - $match: - qty: - $gt: 20 + - name: Match Document Fields + link: https://www.mongodb.com/docs/manual/reference/operator/query/gt/#match-document-fields + pipeline: + - $match: + qty: + $gt: 20 diff --git a/generator/config/query/gte.yaml b/generator/config/query/gte.yaml index d8617a7c6..e12dc1fce 100644 --- a/generator/config/query/gte.yaml +++ b/generator/config/query/gte.yaml @@ -1,22 +1,19 @@ # $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 description: | Matches values that are greater than or equal to a specified value. arguments: - - - name: value - type: - - any + - name: value + type: + - any tests: - - - name: 'Match Document Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/gte/#match-document-fields' - pipeline: - - - $match: - qty: - $gte: 20 + - name: Match Document Fields + link: https://www.mongodb.com/docs/manual/reference/operator/query/gte/#match-document-fields + pipeline: + - $match: + qty: + $gte: 20 diff --git a/generator/config/query/in.yaml b/generator/config/query/in.yaml index 67f069416..c5bd9b1d2 100644 --- a/generator/config/query/in.yaml +++ b/generator/config/query/in.yaml @@ -1,32 +1,29 @@ # $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 description: | Matches any of the values specified in an array. arguments: - - - name: value - type: - - array # of expression + - name: value + type: + - array # of expression 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' - pipeline: - - - $match: - tags: - $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' - pipeline: - - - $match: - tags: - $in: - - !bson_regex '^be' - - !bson_regex '^st' + - 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 + - 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' diff --git a/generator/config/query/jsonSchema.yaml b/generator/config/query/jsonSchema.yaml index 4c1dca6ad..a947cc77c 100644 --- a/generator/config/query/jsonSchema.yaml +++ b/generator/config/query/jsonSchema.yaml @@ -1,39 +1,36 @@ # $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 description: | Validate documents against the given JSON Schema. arguments: - - - name: schema - type: - - object + - name: schema + type: + - object tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/jsonSchema/#syntax' - pipeline: - - - $match: - $jsonSchema: - required: - - 'name' - - 'major' - - 'gpa' - - 'address' - properties: - name: - bsonType: 'string' - description: 'must be a string and is required' - address: - bsonType: 'object' - required: - - 'zipcode' - properties: - street: - bsonType: 'string' - zipcode: - bsonType: 'string' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/query/jsonSchema/#syntax + pipeline: + - $match: + $jsonSchema: + required: + - name + - major + - gpa + - address + properties: + name: + bsonType: string + description: must be a string and is required + address: + bsonType: object + required: + - zipcode + properties: + street: + bsonType: string + zipcode: + bsonType: string diff --git a/generator/config/query/lt.yaml b/generator/config/query/lt.yaml index f1c996ded..635aeff9b 100644 --- a/generator/config/query/lt.yaml +++ b/generator/config/query/lt.yaml @@ -1,22 +1,19 @@ # $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 description: | Matches values that are less than a specified value. arguments: - - - name: value - type: - - any + - name: value + type: + - any tests: - - - name: 'Match Document Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/lt/#match-document-fields' - pipeline: - - - $match: - qty: - $lt: 20 + - name: Match Document Fields + link: https://www.mongodb.com/docs/manual/reference/operator/query/lt/#match-document-fields + pipeline: + - $match: + qty: + $lt: 20 diff --git a/generator/config/query/lte.yaml b/generator/config/query/lte.yaml index e61d01b03..bbf74d293 100644 --- a/generator/config/query/lte.yaml +++ b/generator/config/query/lte.yaml @@ -1,22 +1,19 @@ # $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 description: | Matches values that are less than or equal to a specified value. arguments: - - - name: value - type: - - any + - name: value + type: + - any tests: - - - name: 'Match Document Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/lte/#match-document-fields' - pipeline: - - - $match: - qty: - $lte: 20 + - name: Match Document Fields + link: https://www.mongodb.com/docs/manual/reference/operator/query/lte/#match-document-fields + pipeline: + - $match: + qty: + $lte: 20 diff --git a/generator/config/query/maxDistance.yaml b/generator/config/query/maxDistance.yaml index e95212d23..ea89d03ef 100644 --- a/generator/config/query/maxDistance.yaml +++ b/generator/config/query/maxDistance.yaml @@ -1,13 +1,12 @@ # $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 description: | Specifies a maximum distance to limit the results of $near and $nearSphere queries. The 2dsphere and 2d indexes support $maxDistance. arguments: - - - name: value - type: - - number + - name: value + type: + - number diff --git a/generator/config/query/minDistance.yaml b/generator/config/query/minDistance.yaml index fd467a96f..f4605cfb7 100644 --- a/generator/config/query/minDistance.yaml +++ b/generator/config/query/minDistance.yaml @@ -1,14 +1,13 @@ # $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 description: | Specifies a minimum distance to limit the results of $near and $nearSphere queries. For use with 2dsphere index only. arguments: - - - name: value - type: - - int - - double + - name: value + type: + - int + - double diff --git a/generator/config/query/mod.yaml b/generator/config/query/mod.yaml index 04a187253..692a18f15 100644 --- a/generator/config/query/mod.yaml +++ b/generator/config/query/mod.yaml @@ -1,42 +1,42 @@ # $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 description: | Performs a modulo operation on the value of a field and selects documents with a specified result. arguments: - - - name: divisor - type: - - number - - - name: remainder - type: - - number + - name: divisor + type: + - number + - name: remainder + type: + - number tests: - - - 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] - - - 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] - - - $match: - qty: - $mod: [4.5, 0] - - - $match: - qty: - $mod: [4.99, 0] + - 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 + - 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 + - $match: + qty: + $mod: + - 4.5 + - 0 + - $match: + qty: + $mod: + - 4.99 + - 0 diff --git a/generator/config/query/ne.yaml b/generator/config/query/ne.yaml index a1f5a046b..93f78d24c 100644 --- a/generator/config/query/ne.yaml +++ b/generator/config/query/ne.yaml @@ -1,22 +1,19 @@ # $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 description: | Matches all values that are not equal to a specified value. arguments: - - - name: value - type: - - any + - name: value + type: + - any tests: - - - name: 'Match Document Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/ne/#match-document-fields' - pipeline: - - - $match: - quantity: - $ne: 20 + - name: Match Document Fields + link: https://www.mongodb.com/docs/manual/reference/operator/query/ne/#match-document-fields + pipeline: + - $match: + quantity: + $ne: 20 diff --git a/generator/config/query/near.yaml b/generator/config/query/near.yaml index 89d7f511f..386d0386b 100644 --- a/generator/config/query/near.yaml +++ b/generator/config/query/near.yaml @@ -1,44 +1,39 @@ # $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 description: | Returns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2d indexes support $near. arguments: - - - name: geometry - mergeObject: true - type: - - geometry - - - name: $maxDistance - type: - - number - optional: true - description: | - Distance in meters. Limits the results to those documents that are at most the specified distance from the center point. - - - name: $minDistance - type: - - number - optional: true - description: | - Distance in meters. Limits the results to those documents that are at least the specified distance from the center point. + - name: geometry + mergeObject: true + type: + - geometry + - name: $maxDistance + type: + - number + optional: true + description: | + Distance in meters. Limits the results to those documents that are at most the specified distance from the center point. + - name: $minDistance + type: + - number + optional: true + description: | + 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' - pipeline: - - - $match: - location: - $near: - $geometry: - type: 'Point' - coordinates: - - -73.9667 - - 40.78 - $minDistance: 1000 - $maxDistance: 5000 + - 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 + coordinates: + - -73.9667 + - 40.78 + $minDistance: 1000 + $maxDistance: 5000 diff --git a/generator/config/query/nearSphere.yaml b/generator/config/query/nearSphere.yaml index 72e8e18e9..2868cc9e9 100644 --- a/generator/config/query/nearSphere.yaml +++ b/generator/config/query/nearSphere.yaml @@ -1,42 +1,39 @@ # $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 description: | Returns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. The 2dsphere and 2d indexes support $nearSphere. arguments: - - - name: geometry - mergeObject: true - type: - - geometry - - - name: $maxDistance - type: - - number - optional: true - description: | - Distance in meters. - - - name: $minDistance - type: - - number - optional: true - description: | - Distance in meters. Limits the results to those documents that are at least the specified distance from the center point. + - name: geometry + mergeObject: true + type: + - geometry + - name: $maxDistance + type: + - number + optional: true + description: | + Distance in meters. + - name: $minDistance + type: + - number + optional: true + description: | + 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' - pipeline: - - - $match: - location: - $nearSphere: - $geometry: - type: 'Point' - coordinates: [-73.9667, 40.78] - $minDistance: 1000 - $maxDistance: 5000 + - 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 + $minDistance: 1000 + $maxDistance: 5000 diff --git a/generator/config/query/nin.yaml b/generator/config/query/nin.yaml index 4285e4fe7..36eeeadbd 100644 --- a/generator/config/query/nin.yaml +++ b/generator/config/query/nin.yaml @@ -1,30 +1,28 @@ # $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 description: | Matches none of the values specified in an array. arguments: - - - name: value - type: - - array # of expression + - name: value + type: + - array # of expression tests: - - - 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] - - - 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'] + - 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 + - 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 diff --git a/generator/config/query/nor.yaml b/generator/config/query/nor.yaml index d1ad7159a..739ade2ca 100644 --- a/generator/config/query/nor.yaml +++ b/generator/config/query/nor.yaml @@ -1,58 +1,42 @@ # $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 description: | Joins query clauses with a logical NOR returns all documents that fail to match both clauses. arguments: - - - name: queries - type: - - query - variadic: array - variadicMin: 1 + - name: queries + type: + - query + variadic: array + variadicMin: 1 tests: - - - name: 'Query with Two Expressions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-query-with-two-expressions' - pipeline: - - - $match: - $nor: - - - price: 1.99 - - - sale: true - - - name: 'Additional Comparisons' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and-additional-comparisons' - pipeline: - - - $match: - $nor: - - - price: 1.99 - - - qty: - $lt: 20 - - - sale: true - - - name: '$nor and $exists' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and--exists' - pipeline: - - - $match: - $nor: - - - price: 1.99 - - - price: - $exists: false - - - sale: true - - - sale: - $exists: false + - name: Query with Two Expressions + link: https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-query-with-two-expressions + pipeline: + - $match: + $nor: + - price: 1.99 + - sale: true + - name: Additional Comparisons + link: https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and-additional-comparisons + pipeline: + - $match: + $nor: + - price: 1.99 + - qty: + $lt: 20 + - sale: true + - name: $nor and $exists + link: https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and--exists + pipeline: + - $match: + $nor: + - price: 1.99 + - price: + $exists: false + - sale: true + - sale: + $exists: false diff --git a/generator/config/query/not.yaml b/generator/config/query/not.yaml index eb2b43cdb..142c11795 100644 --- a/generator/config/query/not.yaml +++ b/generator/config/query/not.yaml @@ -1,31 +1,26 @@ # $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 description: | Inverts the effect of a query expression and returns documents that do not match the query expression. arguments: - - - name: expression - type: - - fieldQuery + - name: expression + type: + - fieldQuery tests: - - - name: 'Syntax' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/not/#syntax' - pipeline: - - - $match: - price: - $not: - $gt: 1.99 - - - 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.*' + - name: Syntax + link: https://www.mongodb.com/docs/manual/reference/operator/query/not/#syntax + pipeline: + - $match: + price: + $not: + $gt: 1.99 + - 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.*' diff --git a/generator/config/query/or.yaml b/generator/config/query/or.yaml index ce2b7603c..57d470731 100644 --- a/generator/config/query/or.yaml +++ b/generator/config/query/or.yaml @@ -1,47 +1,36 @@ # $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 description: | Joins query clauses with a logical OR returns all documents that match the conditions of either clause. arguments: - - - name: queries - type: - - query - variadic: array - variadicMin: 1 + - name: queries + type: + - query + variadic: array + variadicMin: 1 tests: - - - name: '$or Clauses' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/or/#-or-clauses-and-indexes' - pipeline: - - - $match: - $or: - - - quantity: - $lt: 20 - - - price: 10 - - - - name: 'Error Handling' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/or/#error-handling' - pipeline: - - - $match: - $or: - - - x: - $eq: 0 - - - $expr: - $eq: - - - $divide: - - 1 - - '$x' - - 3 + - name: $or Clauses + link: https://www.mongodb.com/docs/manual/reference/operator/query/or/#-or-clauses-and-indexes + pipeline: + - $match: + $or: + - quantity: + $lt: 20 + - price: 10 + - name: Error Handling + link: https://www.mongodb.com/docs/manual/reference/operator/query/or/#error-handling + pipeline: + - $match: + $or: + - x: + $eq: 0 + - $expr: + $eq: + - $divide: + - 1 + - $x + - 3 diff --git a/generator/config/query/polygon.yaml b/generator/config/query/polygon.yaml index 1a46f2bc4..c74fbf1d9 100644 --- a/generator/config/query/polygon.yaml +++ b/generator/config/query/polygon.yaml @@ -1,13 +1,12 @@ # $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 description: | Specifies a polygon to using legacy coordinate pairs for $geoWithin queries. The 2d index supports $center. arguments: - - - name: points - type: - - array + - name: points + type: + - array diff --git a/generator/config/query/rand.yaml b/generator/config/query/rand.yaml index 6773ae0d5..316d972f0 100644 --- a/generator/config/query/rand.yaml +++ b/generator/config/query/rand.yaml @@ -1,26 +1,22 @@ # $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 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' - pipeline: - - - $match: - district: 3 - $expr: - $lt: - - 0.5 - - - $rand: {} - - - $project: - _id: 0 - name: 1 - registered: 1 + - 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: + district: 3 + $expr: + $lt: + - 0.5 + - $rand: {} + - $project: + _id: 0 + name: 1 + registered: 1 diff --git a/generator/config/query/regex.yaml b/generator/config/query/regex.yaml index c7e378ddd..033901db0 100644 --- a/generator/config/query/regex.yaml +++ b/generator/config/query/regex.yaml @@ -1,33 +1,27 @@ # $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 description: | Selects documents where values match a specified regular expression. arguments: - - - name: regex - type: - - regex - + - 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' - pipeline: - - - $match: - sku: - $regex: - !bson_regex '789$' - - - 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'] + - 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$' + - 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 diff --git a/generator/config/query/sampleRate.yaml b/generator/config/query/sampleRate.yaml index 9995e2d8b..299719317 100644 --- a/generator/config/query/sampleRate.yaml +++ b/generator/config/query/sampleRate.yaml @@ -1,26 +1,22 @@ # $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 description: | Randomly select documents at a given rate. Although the exact number of documents selected varies on each run, the quantity chosen approximates the sample rate expressed as a percentage of the total number of documents. arguments: - - - name: rate - type: - - resolvesToDouble - description: | - The selection process uses a uniform random distribution. The sample rate is a floating point number between 0 and 1, inclusive, which represents the probability that a given document will be selected as it passes through the pipeline. - For example, a sample rate of 0.33 selects roughly one document in three. + - name: rate + type: + - resolvesToDouble + description: | + The selection process uses a uniform random distribution. The sample rate is a floating point number between 0 and 1, inclusive, which represents the probability that a given document will be selected as it passes through the pipeline. + 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' - pipeline: - - - $match: - $sampleRate: 0.33 - - - $count: 'numMatches' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sampleRate/#examples + pipeline: + - $match: + $sampleRate: 0.33 + - $count: numMatches diff --git a/generator/config/query/size.yaml b/generator/config/query/size.yaml index 629de4035..e1dbec9c1 100644 --- a/generator/config/query/size.yaml +++ b/generator/config/query/size.yaml @@ -1,22 +1,19 @@ # $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 description: | Selects documents if the array field is a specified size. arguments: - - - name: value - type: - - int + - name: value + type: + - 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' - pipeline: - - - $match: - tags: - $size: 3 + - 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: + tags: + $size: 3 diff --git a/generator/config/query/text.yaml b/generator/config/query/text.yaml index 574ee4508..1a6a1c07a 100644 --- a/generator/config/query/text.yaml +++ b/generator/config/query/text.yaml @@ -1,114 +1,92 @@ # $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 description: | Performs text search. arguments: - - - name: $search - type: - - string - description: | - A string of terms that MongoDB parses and uses to query the text index. MongoDB performs a logical OR search of the terms unless specified as a phrase. - - - name: $language - type: - - string - optional: true - description: | - The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer. If not specified, the search uses the default language of the index. - If you specify a default_language value of none, then the text index parses through each word in the field, including stop words, and ignores suffix stemming. - - - name: $caseSensitive - type: - - bool - optional: true - description: | - A boolean flag to enable or disable case sensitive search. Defaults to false; i.e. the search defers to the case insensitivity of the text index. - - - name: $diacriticSensitive - type: - - bool - optional: true - description: | - A boolean flag to enable or disable diacritic sensitive search against version 3 text indexes. Defaults to false; i.e. the search defers to the diacritic insensitivity of the text index. - 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. + - name: $search + type: + - string + description: | + A string of terms that MongoDB parses and uses to query the text index. MongoDB performs a logical OR search of the terms unless specified as a phrase. + - name: $language + type: + - string + optional: true + description: | + The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer. If not specified, the search uses the default language of the index. + If you specify a default_language value of none, then the text index parses through each word in the field, including stop words, and ignores suffix stemming. + - name: $caseSensitive + type: + - bool + optional: true + description: | + A boolean flag to enable or disable case sensitive search. Defaults to false; i.e. the search defers to the case insensitivity of the text index. + - name: $diacriticSensitive + type: + - bool + optional: true + description: | + A boolean flag to enable or disable diacritic sensitive search against version 3 text indexes. Defaults to false; i.e. the search defers to the diacritic insensitivity of the text index. + 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' - pipeline: - - - $match: - $text: - $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' - pipeline: - - - $match: - $text: - $search: 'bake coffee cake' - - - 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' - - - 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' - - - 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' - $caseSensitive: true - - - $match: - $text: - $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' - pipeline: - - - $match: - $text: - $search: 'CAFÉ' - $diacriticSensitive: true - - - 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É' - $diacriticSensitive: true - - - $project: - score: - $meta: 'textScore' - - - $sort: - score: - $meta: 'textScore' - - - $limit: 5 + - 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 + - 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 + - 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 + - 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 + - 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 + $caseSensitive: true + - $match: + $text: + $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 + pipeline: + - $match: + $text: + $search: CAFÉ + $diacriticSensitive: true + - 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É + $diacriticSensitive: true + - $project: + score: + $meta: textScore + - $sort: + score: + $meta: textScore + - $limit: 5 diff --git a/generator/config/query/type.yaml b/generator/config/query/type.yaml index d8cd7bc86..924cc39f1 100644 --- a/generator/config/query/type.yaml +++ b/generator/config/query/type.yaml @@ -1,88 +1,85 @@ # $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 description: | Selects documents if a field is of the specified type. arguments: - - - name: type - type: - - int - - string - variadic: array + - name: type + type: + - int + - string + variadic: array tests: - - - name: 'Querying by Data Type' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-data-type' - pipeline: - - - $match: - zipCode: + - 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] - - - $match: - zipCode: + $type: + - 2 + - $match: + zipCode: # Example uses the short form, the builder always generates the verbose form # $type: 'string' - $type: ['string'] - - - $match: - zipCode: + $type: + - string + - $match: + zipCode: # Example uses the short form, the builder always generates the verbose form # $type: 1 - $type: [1] - - - $match: - zipCode: + $type: + - 1 + - $match: + zipCode: # Example uses the short form, the builder always generates the verbose form # $type: 'double' - $type: ['double'] - - - $match: - zipCode: + $type: + - double + - $match: + zipCode: # Example uses the short form, the builder always generates the verbose form # $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' - pipeline: - - - $match: - zipCode: - $type: [2, 1] - - - $match: - zipCode: - $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' - pipeline: - - - $match: - zipCode: + $type: + - number + - 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 + - $match: + zipCode: + $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 + pipeline: + - $match: + zipCode: # Example uses the short form, the builder always generates the verbose form # $type: 'minKey' - $type: ['minKey'] - - - $match: - zipCode: + $type: + - minKey + - $match: + zipCode: # Example uses the short form, the builder always generates the verbose form # $type: 'maxKey' - $type: ['maxKey'] - - - name: 'Querying by Array Type' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-array-type' - pipeline: - - - $match: - zipCode: + $type: + - maxKey + - 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..900862387 100644 --- a/generator/config/query/where.yaml +++ b/generator/config/query/where.yaml @@ -1,36 +1,33 @@ # $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 description: | Matches documents that satisfy a JavaScript expression. arguments: - - - name: function - type: - - javascript + - name: function + type: + - javascript tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/query/where/#example' - pipeline: - - - $match: - $where: - $code: |- - function() { - return hex_md5(this.name) == "9b53e667f30cd329dca1ec9e6a83e994" - } - - - $match: - $expr: - $function: - body: - $code: |- - function(name) { - return hex_md5(name) == "9b53e667f30cd329dca1ec9e6a83e994"; - } - args: ['$name'] - lang: 'js' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/query/where/#example + pipeline: + - $match: + $where: + $code: |- + function() { + return hex_md5(this.name) == "9b53e667f30cd329dca1ec9e6a83e994" + } + - $match: + $expr: + $function: + body: + $code: |- + function(name) { + return hex_md5(name) == "9b53e667f30cd329dca1ec9e6a83e994"; + } + 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..508d3b1d2 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 @@ -10,143 +10,107 @@ description: | fields that you intend to query with the autocomplete operator must be indexed with the autocomplete data type in the collection's index definition. arguments: - - - name: path - type: - - searchPath - - - name: query - type: - - string - - - name: tokenOrder - optional: true - type: - - string # any|sequential - - - name: fuzzy - optional: true - type: - - object - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: query + type: + - string + - name: tokenOrder + optional: true + type: + - string # any|sequential + - name: fuzzy + optional: true + type: + - object + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Basic' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#basic-example' - pipeline: - - - $search: - autocomplete: - query: 'off' - path: 'title' - - - $limit: 10 - - - $project: - _id: 0 - title: 1 - - - - name: 'Fuzzy' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#fuzzy-example' - pipeline: - - - $search: - autocomplete: - query: 'pre' - path: 'title' - fuzzy: - maxEdits: 1 - prefixLength: 1 - maxExpansions: 256 - - - $limit: 10 - - - $project: - _id: 0 - title: 1 - - - - 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' - - - $limit: 4 - - - $project: - _id: 0 - title: 1 - - - - 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' - - - $limit: 4 - - - $project: - _id: 0 - title: 1 - - - - name: 'Highlighting' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#highlighting-example' - pipeline: - - - $search: - autocomplete: - query: 'ger' - path: 'title' - highlight: - path: 'title' - - - $limit: 5 - - - $project: - score: - $meta: 'searchScore' - _id: 0 - title: 1 - highlights: - $meta: 'searchHighlights' - - - - name: 'Across Multiple Fields' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#search-across-multiple-fields' - pipeline: - - - $search: - compound: - should: - - - autocomplete: - query: 'inter' - path: 'title' - - - autocomplete: - query: 'inter' - path: 'plot' - minimumShouldMatch: 1 - - - $limit: 10 - - - $project: - _id: 0 - title: 1 - plot: 1 + - name: Basic + link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#basic-example + pipeline: + - $search: + autocomplete: + query: 'off' + path: title + - $limit: 10 + - $project: + _id: 0 + title: 1 + - name: Fuzzy + link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#fuzzy-example + pipeline: + - $search: + autocomplete: + query: pre + path: title + fuzzy: + maxEdits: 1 + prefixLength: 1 + maxExpansions: 256 + - $limit: 10 + - $project: + _id: 0 + title: 1 + - 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 + - $limit: 4 + - $project: + _id: 0 + title: 1 + - 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 + - $limit: 4 + - $project: + _id: 0 + title: 1 + - name: Highlighting + link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#highlighting-example + pipeline: + - $search: + autocomplete: + query: ger + path: title + highlight: + path: title + - $limit: 5 + - $project: + score: + $meta: searchScore + _id: 0 + title: 1 + highlights: + $meta: searchHighlights + - name: Across Multiple Fields + link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#search-across-multiple-fields + pipeline: + - $search: + compound: + should: + - autocomplete: + query: inter + path: title + - autocomplete: + query: inter + path: plot + minimumShouldMatch: 1 + - $limit: 10 + - $project: + _id: 0 + title: 1 + plot: 1 diff --git a/generator/config/search/compound.yaml b/generator/config/search/compound.yaml index 7a1d9f419..6426e5168 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 @@ -9,148 +9,113 @@ description: | Each element of a compound query is called a clause, and each clause consists of one or more sub-queries. arguments: - - - name: must - optional: true - type: - - searchOperator - - array # of searchOperator - - - name: mustNot - optional: true - type: - - searchOperator - - array # of searchOperator - - - name: should - optional: true - type: - - searchOperator - - array # of searchOperator - - - name: filter - optional: true - type: - - searchOperator - - array # of searchOperator - - - name: minimumShouldMatch - optional: true - type: - - int - - - name: score - optional: true - type: - - searchScore + - name: must + optional: true + type: + - searchOperator + - array # of searchOperator + - name: mustNot + optional: true + type: + - searchOperator + - array # of searchOperator + - name: should + optional: true + type: + - searchOperator + - array # of searchOperator + - name: filter + optional: true + type: + - searchOperator + - array # of searchOperator + - name: minimumShouldMatch + optional: true + type: + - int + - name: score + optional: true + type: + - searchScore tests: - - - name: 'must and mustNot' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#must-and-mustnot-example' - pipeline: - - - $search: - compound: - must: - - - text: - query: 'varieties' - path: 'description' - mustNot: - - - text: - query: 'apples' - path: 'description' - - - - name: 'must and should' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#must-and-should-example' - pipeline: - - - $search: - compound: - must: - - - text: - query: 'varieties' - path: 'description' - should: - - - text: - query: 'Fuji' - path: 'description' - - - $project: - score: - $meta: 'searchScore' - - - - name: 'minimumShouldMatch' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#minimumshouldmatch-example' - pipeline: - - - $search: - compound: - must: - - - text: - query: 'varieties' - path: 'description' - should: - - - text: - query: 'Fuji' - path: 'description' - - - text: - query: 'Golden Delicious' - path: 'description' - minimumShouldMatch: 1 - - - - name: 'Filter' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#filter-examples' - pipeline: - - - $search: - compound: - must: - - - text: - query: 'varieties' - path: 'description' - should: - - - text: - query: 'banana' - path: 'description' - filter: - - - text: - query: 'granny' - path: 'description' - - - - name: 'Nested' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#nested-example' - pipeline: - - - $search: - compound: - should: - - - text: - query: 'apple' - path: 'type' - - - compound: - must: - - - text: - query: 'organic' - path: 'category' - - - equals: - value: true - path: 'in_stock' - minimumShouldMatch: 1 + - name: must and mustNot + link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#must-and-mustnot-example + pipeline: + - $search: + compound: + must: + - text: + query: varieties + path: description + mustNot: + - text: + query: apples + path: description + - name: must and should + link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#must-and-should-example + pipeline: + - $search: + compound: + must: + - text: + query: varieties + path: description + should: + - text: + query: Fuji + path: description + - $project: + score: + $meta: searchScore + - name: minimumShouldMatch + link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#minimumshouldmatch-example + pipeline: + - $search: + compound: + must: + - text: + query: varieties + path: description + should: + - text: + query: Fuji + path: description + - text: + query: Golden Delicious + path: description + minimumShouldMatch: 1 + - name: Filter + link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#filter-examples + pipeline: + - $search: + compound: + must: + - text: + query: varieties + path: description + should: + - text: + query: banana + path: description + filter: + - text: + query: granny + path: description + - name: Nested + link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#nested-example + pipeline: + - $search: + compound: + should: + - text: + query: apple + path: type + - compound: + must: + - text: + query: organic + path: category + - equals: + value: true + path: in_stock + minimumShouldMatch: 1 diff --git a/generator/config/search/embeddedDocument.yaml b/generator/config/search/embeddedDocument.yaml index 19c804625..17f68f5ee 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 @@ -10,146 +10,116 @@ description: | element of an array of embedded documents. embeddedDocument can be used only for queries over fields of the embeddedDocuments arguments: - - - name: path - type: - - searchPath - - - name: operator - type: - - searchOperator - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: operator + type: + - searchOperator + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Basic' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#index-definition' - pipeline: - - - $search: - embeddedDocument: - path: 'items' - operator: - compound: - must: - - - text: - path: 'items.tags' - query: 'school' - should: - - - text: - path: 'items.name' - query: 'backpack' - score: - embedded: - aggregate: 'mean' - - - $limit: 5 - - - $project: - _id: 0 - items.name: 1 - items.tags: 1 + - name: Basic + link: https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#index-definition + pipeline: + - $search: + embeddedDocument: + path: items + operator: + compound: + must: + - text: + path: items.tags + query: school + should: + - text: + path: items.name + query: backpack score: - $meta: 'searchScore' - - - - name: 'Facet' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#facet-query' - pipeline: - - - $searchMeta: - facet: - operator: - embeddedDocument: - path: 'items' - operator: - compound: - must: - - - text: - path: 'items.tags' - query: 'school' - should: - - - text: - path: 'items.name' - query: 'backpack' - facets: - purchaseMethodFacet: - type: 'string' - path: 'purchaseMethod' - - - - name: 'Query and Sort' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#query-and-sort' - pipeline: - - - $search: - embeddedDocument: - path: 'items' - operator: - text: - path: 'items.name' - query: 'laptop' - sort: - items.tags: 1 - - - $limit: 5 - - - $project: - _id: 0 - items.name: 1 + embedded: + aggregate: mean + - $limit: 5 + - $project: + _id: 0 + items.name: 1 + items.tags: 1 + score: + $meta: searchScore + - name: Facet + link: https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#facet-query + pipeline: + - $searchMeta: + facet: + operator: + embeddedDocument: + path: items + operator: + compound: + must: + - text: + path: items.tags + query: school + should: + - text: + path: items.name + query: backpack + facets: + purchaseMethodFacet: + type: string + path: purchaseMethod + - name: Query and Sort + link: https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#query-and-sort + pipeline: + - $search: + embeddedDocument: + path: items + operator: + text: + path: items.name + query: laptop + sort: items.tags: 1 - score: - $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' - pipeline: - - - $search: - embeddedDocument: - path: 'items' - operator: - compound: - must: - - - range: - path: 'items.quantity' - gt: 2 - - - exists: - path: 'items.price' - - - text: - path: 'items.tags' - query: 'school' - - - $limit: 2 - - - $project: - _id: 0 - storeLocation: 1 - items: - $filter: - input: '$items' - cond: - $and: - - - $ifNull: - - '$$this.price' - - 'false' - - - $gt: - - '$$this.quantity' - - 2 - - - $in: - - 'office' - - '$$this.tags' + - $limit: 5 + - $project: + _id: 0 + items.name: 1 + items.tags: 1 + score: + $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 + pipeline: + - $search: + embeddedDocument: + path: items + operator: + compound: + must: + - range: + path: items.quantity + gt: 2 + - exists: + path: items.price + - text: + path: items.tags + query: school + - $limit: 2 + - $project: + _id: 0 + storeLocation: 1 + items: + $filter: + input: $items + cond: + $and: + - $ifNull: + - $$this.price + - 'false' + - $gt: + - $$this.quantity + - 2 + - $in: + - office + - $$this.tags diff --git a/generator/config/search/equals.yaml b/generator/config/search/equals.yaml index b3e50c641..f3fc4fa2b 100644 --- a/generator/config/search/equals.yaml +++ b/generator/config/search/equals.yaml @@ -1,104 +1,80 @@ # $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 description: | The equals operator checks whether a field matches a value you specify. arguments: - - - name: path - type: - - searchPath - - - name: value - type: - - binData - - bool - - date - - objectId - - 'null' - - number - - string - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: value + type: + - binData + - bool + - date + - objectId + - 'null' + - number + - string + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Boolean' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#boolean-examples' - pipeline: - - - $search: - equals: - path: 'verified_user' - value: true - - - $project: - name: 1 - _id: 0 - score: - $meta: 'searchScore' - - - - name: 'ObjectId' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#objectid-example' - pipeline: - - - $search: - equals: - path: 'teammates' - value: !bson_objectId '5a9427648b0beebeb69589a1' - - - - 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' - - - - name: 'Number' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#number-example' - pipeline: - - - $search: - equals: - path: 'employee_number' - value: 259 - - - - name: 'String' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#string-example' - pipeline: - - - $search: - equals: - path: 'name' - value: 'jim hall' - - - - 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' - - - - name: 'Null' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#null-example' - pipeline: - - - $search: - equals: - path: 'job_title' - value: ~ + - name: Boolean + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#boolean-examples + pipeline: + - $search: + equals: + path: verified_user + value: true + - $project: + name: 1 + _id: 0 + score: + $meta: searchScore + - name: ObjectId + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#objectid-example + pipeline: + - $search: + equals: + path: teammates + value: !bson_objectId '5a9427648b0beebeb69589a1' + - 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' + - name: Number + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#number-example + pipeline: + - $search: + equals: + path: employee_number + value: 259 + - name: String + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#string-example + pipeline: + - $search: + equals: + path: name + value: jim hall + - 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' + - name: 'Null' + link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#null-example + pipeline: + - $search: + equals: + path: job_title + value: ~ diff --git a/generator/config/search/exists.yaml b/generator/config/search/exists.yaml index 062e8ba59..a339b7b06 100644 --- a/generator/config/search/exists.yaml +++ b/generator/config/search/exists.yaml @@ -1,56 +1,44 @@ # $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 description: | The exists operator tests if a path to a specified indexed field name exists in a document. arguments: - - - name: path - type: - - searchPath - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Basic' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/#basic-example' - pipeline: - - - $search: - exists: - path: 'type' - - - - name: 'Embedded' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/#embedded-example' - pipeline: - - - $search: - exists: - path: 'quantities.lemons' - - - - name: 'Compound' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/#compound-example' - pipeline: - - - $search: - compound: - must: - - - exists: - path: 'type' - - - text: - query: 'apple' - path: 'type' - should: - text: - query: 'fuji' - path: 'description' + - name: Basic + link: https://www.mongodb.com/docs/atlas/atlas-search/exists/#basic-example + pipeline: + - $search: + exists: + path: type + - name: Embedded + link: https://www.mongodb.com/docs/atlas/atlas-search/exists/#embedded-example + pipeline: + - $search: + exists: + path: quantities.lemons + - name: Compound + link: https://www.mongodb.com/docs/atlas/atlas-search/exists/#compound-example + pipeline: + - $search: + compound: + must: + - exists: + path: type + - text: + query: apple + path: type + should: + text: + query: fuji + path: description diff --git a/generator/config/search/facet.yaml b/generator/config/search/facet.yaml index 53dc8cba9..39f691919 100644 --- a/generator/config/search/facet.yaml +++ b/generator/config/search/facet.yaml @@ -1,6 +1,6 @@ # $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 encode: object @@ -8,49 +8,39 @@ description: | The facet collector groups results by values or ranges in the specified faceted fields and returns the count for each of those groups. arguments: - - - name: facets - type: - - object # map of facetDefinition - - - name: operator - optional: true - type: - - searchOperator + - name: facets + type: + - object # map of facetDefinition + - name: operator + optional: true + type: + - searchOperator tests: - - - 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' - pivot: 7776000000 - facets: - genresFacet: - type: 'string' - path: 'genres' - - - $limit: 2 - - - $facet: - docs: - - - $project: - title: 1 - released: 1 - meta: - - - $replaceWith: '$$SEARCH_META' - - - $limit: 1 - - - $set: - meta: - $arrayElemAt: - - '$meta' - - 0 + - 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' + pivot: 7776000000 + facets: + genresFacet: + type: string + path: genres + - $limit: 2 + - $facet: + docs: + - $project: + title: 1 + released: 1 + meta: + - $replaceWith: $$SEARCH_META + - $limit: 1 + - $set: + meta: + $arrayElemAt: + - $meta + - 0 diff --git a/generator/config/search/geoShape.yaml b/generator/config/search/geoShape.yaml index 4da121e45..1e4f89ce8 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 @@ -8,116 +8,92 @@ description: | The geoShape operator supports querying shapes with a relation to a given geometry if indexShapes is set to true in the index definition. arguments: - - - name: path - type: - - searchPath - - - name: relation - type: - - string # contains | disjoint | intersects | within - - - name: geometry - type: - - geometry - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: relation + type: + - string # contains | disjoint | intersects | within + - name: geometry + type: + - geometry + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Disjoint' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#disjoint-example' - pipeline: - - - $search: - geoShape: - relation: 'disjoint' - geometry: - type: 'Polygon' - coordinates: - - - - [-161.323242, 22.512557] - - [-152.446289, 22.065278] - - [-156.09375, 17.811456] - - [-161.323242, 22.512557] - path: 'address.location' - - - $limit: 3 - - - $project: - _id: 0 - name: 1 - address: 1 - score: - $meta: 'searchScore' - - - - name: 'Intersect' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#intersects-example' - pipeline: - - - $search: - geoShape: - relation: 'intersects' - geometry: - type: 'MultiPolygon' - coordinates: - - - - - - [2.16942, 41.40082] + - name: Disjoint + link: https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#disjoint-example + pipeline: + - $search: + geoShape: + relation: disjoint + geometry: + type: Polygon + coordinates: + - - [-161.323242, 22.512557] + - [-152.446289, 22.065278] + - [-156.09375, 17.811456] + - [-161.323242, 22.512557] + path: address.location + - $limit: 3 + - $project: + _id: 0 + name: 1 + address: 1 + score: + $meta: searchScore + - name: Intersect + link: https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#intersects-example + pipeline: + - $search: + geoShape: + relation: intersects + geometry: + 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.16365, 41.39416] + - - - [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 - - - $project: - _id: 0 - name: 1 - address: 1 - score: - $meta: 'searchScore' - - - - name: 'Within' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#within-example' - pipeline: - - - $search: - geoShape: - relation: 'within' - geometry: - 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' - - - $limit: 3 - - - $project: - _id: 0 - name: 1 - address: 1 - score: - $meta: 'searchScore' + path: address.location + - $limit: 3 + - $project: + _id: 0 + name: 1 + address: 1 + score: + $meta: searchScore + - name: Within + link: https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#within-example + pipeline: + - $search: + geoShape: + relation: within + geometry: + 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 + - $limit: 3 + - $project: + _id: 0 + name: 1 + address: 1 + score: + $meta: searchScore diff --git a/generator/config/search/geoWithin.yaml b/generator/config/search/geoWithin.yaml index 1739f1997..eef050c3d 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 @@ -9,95 +9,81 @@ description: | geometry. Only points are returned, even if indexShapes value is true in the index definition. arguments: - - - name: path - type: - - searchPath - - - name: box - optional: true - type: - - object - - - name: circle - optional: true - type: - - object - - - name: geometry - optional: true - type: - - geometry - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: box + optional: true + type: + - object + - name: circle + optional: true + type: + - object + - name: geometry + optional: true + type: + - geometry + - name: score + optional: true + type: + - searchScore tests: - - - name: 'box' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#box-example' - pipeline: - - - $search: - geoWithin: - path: 'address.location' - box: - bottomLeft: - type: 'Point' - coordinates: [112.467, -55.05] - topRight: - type: 'Point' - coordinates: [168, -9.133] - - - $limit: 3 - - - $project: - _id: 0 - name: 1 - address: 1 - - - - 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] - radius: 1600 - path: 'address.location' - - - $limit: 3 - - - $project: - _id: 0 - name: 1 - address: 1 - - - - name: 'geometry' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#geometry-examples' - pipeline: - - - $search: - geoWithin: - geometry: - type: 'Polygon' + - name: box + link: https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#box-example + pipeline: + - $search: + geoWithin: + path: address.location + box: + bottomLeft: + type: Point coordinates: - - - - [-161.323242, 22.512557] - - [-152.446289, 22.065278] - - [-156.09375, 17.811456] - - [-161.323242, 22.512557] - path: 'address.location' - - - $limit: 3 - - - $project: - _id: 0 - name: 1 - address: 1 + - 112.467 + - -55.05 + topRight: + type: Point + coordinates: + - 168 + - -9.133 + - $limit: 3 + - $project: + _id: 0 + name: 1 + address: 1 + - 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 + radius: 1600 + path: address.location + - $limit: 3 + - $project: + _id: 0 + name: 1 + address: 1 + - name: geometry + link: https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#geometry-examples + pipeline: + - $search: + geoWithin: + geometry: + type: Polygon + coordinates: + - - [-161.323242, 22.512557] + - [-152.446289, 22.065278] + - [-156.09375, 17.811456] + - [-161.323242, 22.512557] + path: address.location + - $limit: 3 + - $project: + _id: 0 + name: 1 + address: 1 diff --git a/generator/config/search/in.yaml b/generator/config/search/in.yaml index cc1aa6c33..94182b2e1 100644 --- a/generator/config/search/in.yaml +++ b/generator/config/search/in.yaml @@ -1,89 +1,72 @@ # $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 description: | The in operator performs a search for an array of BSON values in a field. arguments: - - - name: path - type: - - searchPath - - - name: value - type: - - any - - array # of any - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: value + type: + - any + - array # of any + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Single Value Field Match' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/in/#examples' - pipeline: - - - $search: - in: - 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' - - - $project: - _id: 0 - name: 1 - birthdate: 1 - - - - name: 'Array Value Field Match' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/in/#examples' - pipeline: - - - $search: - in: - path: 'accounts' - value: - - 371138 - - 371139 - - 371140 - - - $project: - _id: 0 - name: 1 - accounts: 1 - - - - name: 'Compound Query Match' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/in/#examples' - pipeline: - - - $search: - compound: - must: - - - in: - path: 'name' - value: - - 'james sanchez' - - 'jennifer lawrence' - should: - - - in: - path: '_id' - value: - - !bson_objectId '5ca4bbcea2dd94ee58162a72' - - !bson_objectId '5ca4bbcea2dd94ee58162a91' - - - $limit: 5 - - - $project: - _id: 1 - name: 1 - score: - $meta: 'searchScore' + - name: Single Value Field Match + link: https://www.mongodb.com/docs/atlas/atlas-search/in/#examples + pipeline: + - $search: + in: + 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' + - $project: + _id: 0 + name: 1 + birthdate: 1 + - name: Array Value Field Match + link: https://www.mongodb.com/docs/atlas/atlas-search/in/#examples + pipeline: + - $search: + in: + path: accounts + value: + - 371138 + - 371139 + - 371140 + - $project: + _id: 0 + name: 1 + accounts: 1 + - name: Compound Query Match + link: https://www.mongodb.com/docs/atlas/atlas-search/in/#examples + pipeline: + - $search: + compound: + must: + - in: + path: name + value: + - james sanchez + - jennifer lawrence + should: + - in: + path: _id + value: + - !bson_objectId '5ca4bbcea2dd94ee58162a72' + - !bson_objectId '5ca4bbcea2dd94ee58162a91' + - $limit: 5 + - $project: + _id: 1 + name: 1 + score: + $meta: searchScore diff --git a/generator/config/search/moreLikeThis.yaml b/generator/config/search/moreLikeThis.yaml index 8c4803bdd..d5cb1d3fb 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 @@ -9,91 +9,71 @@ description: | The moreLikeThis operator allows you to build features for your applications that display similar or alternative results based on one or more given documents. arguments: - - - name: like - type: - - object - - array # of object - - - name: score - optional: true - type: - - searchScore + - name: like + type: + - object + - array # of object + - name: score + optional: true + type: + - 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' - pipeline: - - - $search: - moreLikeThis: - like: - title: 'The Godfather' - genres: 'action' - - - $limit: 5 - - - $project: - _id: 0 - 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' - pipeline: - - - $search: - compound: - must: - - - moreLikeThis: - like: - _id: !bson_objectId '573a1396f29313caabce4a9a' - genres: - - 'Crime' - - 'Drama' - title: 'The Godfather' - mustNot: - - - equals: - path: '_id' - value: !bson_objectId '573a1396f29313caabce4a9a' - - - $limit: 5 - - - $project: - _id: 1 - title: 1 - released: 1 - genres: 1 - - - - name: 'Multiple Analyzers' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-3--multiple-analyzers' - pipeline: - - - $search: - compound: - should: - - - moreLikeThis: - like: - _id: !bson_objectId '573a1396f29313caabce4a9a' - genres: - - 'Crime' - - 'Drama' - title: 'The Godfather' - mustNot: - - - equals: - path: '_id' - value: !bson_objectId '573a1394f29313caabcde9ef' - - - $limit: 10 - - - $project: - title: 1 - genres: 1 - _id: 1 + - 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 + - $limit: 5 + - $project: + _id: 0 + 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 + pipeline: + - $search: + compound: + must: + - moreLikeThis: + like: + _id: !bson_objectId '573a1396f29313caabce4a9a' + genres: + - Crime + - Drama + title: The Godfather + mustNot: + - equals: + path: _id + value: !bson_objectId '573a1396f29313caabce4a9a' + - $limit: 5 + - $project: + _id: 1 + title: 1 + released: 1 + genres: 1 + - name: Multiple Analyzers + link: https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-3--multiple-analyzers + pipeline: + - $search: + compound: + should: + - moreLikeThis: + like: + _id: !bson_objectId '573a1396f29313caabce4a9a' + genres: + - Crime + - Drama + title: The Godfather + mustNot: + - equals: + path: _id + value: !bson_objectId '573a1394f29313caabcde9ef' + - $limit: 10 + - $project: + title: 1 + genres: 1 + _id: 1 diff --git a/generator/config/search/near.yaml b/generator/config/search/near.yaml index bd4119cf9..8c6a7e5de 100644 --- a/generator/config/search/near.yaml +++ b/generator/config/search/near.yaml @@ -1,124 +1,101 @@ # $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 description: | The near operator supports querying and scoring numeric, date, and GeoJSON point values. arguments: - - - name: path - type: - - searchPath - - - name: origin - type: - - date - - number - - geometry - - - name: pivot - type: - - number - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: origin + type: + - date + - number + - geometry + - name: pivot + type: + - number + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Number' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#number-example' - pipeline: - - - $search: - index: 'runtimes' - near: - path: 'runtime' - origin: 279 - pivot: 2 - - - $limit: 7 - - - $project: - _id: 0 - title: 1 - runtime: 1 - score: - $meta: 'searchScore' - - - - name: 'Date' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#date-example' - pipeline: - - - $search: - index: 'releaseddate' - near: - path: 'released' - origin: !bson_utcdatetime '1915-09-13T00:00:00.000+00:00' - pivot: 7776000000 - - - $limit: 3 - - - $project: - _id: 0 - title: 1 - released: 1 - score: - $meta: 'searchScore' - - - - name: 'GeoJSON Point' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#geojson-point-examples' - pipeline: - - - $search: - near: - origin: - type: 'Point' - coordinates: - - -8.61308 - - 41.1413 - pivot: 1000 - path: 'address.location' - - - $limit: 3 - - - $project: - _id: 0 - name: 1 - address: 1 - score: - $meta: 'searchScore' - - - - name: 'Compound' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#compound-example' - pipeline: - - - $search: - compound: - must: - text: - query: 'Apartment' - path: 'property_type' - should: - near: - origin: - type: 'Point' - coordinates: - - 114.15027 - - 22.28158 - pivot: 1000 - path: 'address.location' - - - $limit: 3 - - - $project: - _id: 0 - property_type: 1 - address: 1 - score: - $meta: 'searchScore' + - name: Number + link: https://www.mongodb.com/docs/atlas/atlas-search/near/#number-example + pipeline: + - $search: + index: runtimes + near: + path: runtime + origin: 279 + pivot: 2 + - $limit: 7 + - $project: + _id: 0 + title: 1 + runtime: 1 + score: + $meta: searchScore + - name: Date + link: https://www.mongodb.com/docs/atlas/atlas-search/near/#date-example + pipeline: + - $search: + index: releaseddate + near: + path: released + origin: !bson_utcdatetime '1915-09-13T00:00:00.000+00:00' + pivot: 7776000000 + - $limit: 3 + - $project: + _id: 0 + title: 1 + released: 1 + score: + $meta: searchScore + - name: GeoJSON Point + link: https://www.mongodb.com/docs/atlas/atlas-search/near/#geojson-point-examples + pipeline: + - $search: + near: + origin: + type: Point + coordinates: + - -8.61308 + - 41.1413 + pivot: 1000 + path: address.location + - $limit: 3 + - $project: + _id: 0 + name: 1 + address: 1 + score: + $meta: searchScore + - name: Compound + link: https://www.mongodb.com/docs/atlas/atlas-search/near/#compound-example + pipeline: + - $search: + compound: + must: + text: + query: Apartment + path: property_type + should: + near: + origin: + type: Point + coordinates: + - 114.15027 + - 22.28158 + pivot: 1000 + path: address.location + - $limit: 3 + - $project: + _id: 0 + property_type: 1 + address: 1 + score: + $meta: searchScore diff --git a/generator/config/search/phrase.yaml b/generator/config/search/phrase.yaml index 4d9b75c4e..edf2cfe2c 100644 --- a/generator/config/search/phrase.yaml +++ b/generator/config/search/phrase.yaml @@ -1,109 +1,86 @@ # $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 description: | The phrase operator performs search for documents containing an ordered sequence of terms using the analyzer specified in the index configuration. arguments: - - - name: path - type: - - searchPath - - - name: query - type: - - string - - array # of string - - - name: slop - optional: true - type: - - int - - - name: synonyms - optional: true - type: - - string - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: query + type: + - string + - array # of string + - name: slop + optional: true + type: + - int + - name: synonyms + optional: true + type: + - string + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Single Phrase' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#single-phrase-example' - pipeline: - - - $search: - phrase: - path: 'title' - query: 'new york' - - - $limit: 10 - - - $project: - _id: 0 - title: 1 - score: - $meta: 'searchScore' - - - - name: 'Multiple Phrase' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#multiple-phrases-example' - pipeline: - - - $search: - phrase: - path: 'title' - query: - - 'the man' - - 'the moon' - - - $limit: 10 - - - $project: - _id: 0 - title: 1 - score: - $meta: 'searchScore' - - - - name: 'Phrase Slop' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#slop-example' - pipeline: - - - $search: - phrase: - path: 'title' - query: 'men women' - slop: 5 - - - $project: - _id: 0 - title: 1 - score: - $meta: 'searchScore' - - - - name: 'Phrase Synonyms' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#synonyms-example' - pipeline: - - - $search: - phrase: - path: 'plot' - query: 'automobile race' - slop: 5 - synonyms: 'my_synonyms' - - - $limit: 5 - - - $project: - _id: 0 - plot: 1 - title: 1 - score: - $meta: 'searchScore' + - name: Single Phrase + link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/#single-phrase-example + pipeline: + - $search: + phrase: + path: title + query: new york + - $limit: 10 + - $project: + _id: 0 + title: 1 + score: + $meta: searchScore + - name: Multiple Phrase + link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/#multiple-phrases-example + pipeline: + - $search: + phrase: + path: title + query: + - the man + - the moon + - $limit: 10 + - $project: + _id: 0 + title: 1 + score: + $meta: searchScore + - name: Phrase Slop + link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/#slop-example + pipeline: + - $search: + phrase: + path: title + query: men women + slop: 5 + - $project: + _id: 0 + title: 1 + score: + $meta: searchScore + - name: Phrase Synonyms + link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/#synonyms-example + pipeline: + - $search: + phrase: + path: plot + query: automobile race + slop: 5 + synonyms: my_synonyms + - $limit: 5 + - $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: searchScore diff --git a/generator/config/search/queryString.yaml b/generator/config/search/queryString.yaml index 8202771c9..c19ca1d08 100644 --- a/generator/config/search/queryString.yaml +++ b/generator/config/search/queryString.yaml @@ -1,35 +1,28 @@ # $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: | - arguments: - - - name: defaultPath - type: - - searchPath - - - name: query - type: - - string - + - name: defaultPath + type: + - searchPath + - 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' - pipeline: - - - $search: - queryString: - defaultPath: 'title' - query: 'Rocky AND (IV OR 4 OR Four)' - - - $project: - _id: 0 - title: 1 + - 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) + - $project: + _id: 0 + title: 1 diff --git a/generator/config/search/range.yaml b/generator/config/search/range.yaml index f42c69176..124aa9688 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 @@ -8,132 +8,103 @@ description: | The range operator supports querying and scoring numeric, date, and string values. You can use this operator to find results that are within a given numeric, date, objectId, or letter (from the English alphabet) range. arguments: - - - name: path - type: - - searchPath - - - name: gt - optional: true - type: - - date - - number - - string - - objectId - - - name: gte - optional: true - type: - - date - - number - - string - - objectId - - - name: lt - optional: true - type: - - date - - number - - string - - objectId - - - name: lte - optional: true - type: - - date - - number - - string - - objectId - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: gt + optional: true + type: + - date + - number + - string + - objectId + - name: gte + optional: true + type: + - date + - number + - string + - objectId + - name: lt + optional: true + type: + - date + - number + - string + - objectId + - name: lte + optional: true + type: + - date + - number + - string + - objectId + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Number gte lte' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#number-example' - pipeline: - - - $search: - range: - path: 'runtime' - gte: 2 - lte: 3 - - - $limit: 5 - - - $project: - _id: 0 - title: 1 - runtime: 1 - - - - name: 'Number lte' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#number-example' - pipeline: - - - $search: - range: - path: 'runtime' - lte: 2 - - - $limit: 5 - - - $project: - _id: 0 - title: 1 - runtime: 1 - score: - $meta: 'searchScore' - - - - 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' - - - $limit: 5 - - - $project: - _id: 0 - title: 1 - released: 1 - - - - 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' - - - $project: - _id: 1 - title: 1 - released: 1 - - - - name: 'String' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#string-example' - pipeline: - - - $search: - range: - path: 'title' - gt: 'city' - lt: 'country' - - - $limit: 5 - - - $project: - _id: 0 - title: 1 + - name: Number gte lte + link: https://www.mongodb.com/docs/atlas/atlas-search/range/#number-example + pipeline: + - $search: + range: + path: runtime + gte: 2 + lte: 3 + - $limit: 5 + - $project: + _id: 0 + title: 1 + runtime: 1 + - name: Number lte + link: https://www.mongodb.com/docs/atlas/atlas-search/range/#number-example + pipeline: + - $search: + range: + path: runtime + lte: 2 + - $limit: 5 + - $project: + _id: 0 + title: 1 + runtime: 1 + score: + $meta: searchScore + - 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' + - $limit: 5 + - $project: + _id: 0 + title: 1 + released: 1 + - 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' + - $project: + _id: 1 + title: 1 + released: 1 + - name: String + link: https://www.mongodb.com/docs/atlas/atlas-search/range/#string-example + pipeline: + - $search: + range: + path: title + gt: city + lt: country + - $limit: 5 + - $project: + _id: 0 + title: 1 diff --git a/generator/config/search/regex.yaml b/generator/config/search/regex.yaml index 869ffabde..44d733491 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 @@ -8,35 +8,28 @@ description: | regex interprets the query field as a regular expression. regex is a term-level operator, meaning that the query field isn't analyzed. arguments: - - - name: path - type: - - searchPath - - - name: query - type: - - string - - - name: allowAnalyzedField - optional: true - type: - - bool - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: query + type: + - string + - name: allowAnalyzedField + optional: true + type: + - bool + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Regex' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/regex/#examples' - pipeline: - - - $search: - regex: - path: 'title' - query: '[0-9]{2} (.){4}s' - - - $project: - _id: 0 - title: 1 + - name: Regex + link: https://www.mongodb.com/docs/atlas/atlas-search/regex/#examples + pipeline: + - $search: + regex: + path: title + query: '[0-9]{2} (.){4}s' + - $project: + _id: 0 + title: 1 diff --git a/generator/config/search/text.yaml b/generator/config/search/text.yaml index dbd48cdd0..9b215d76e 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 @@ -8,187 +8,145 @@ description: | The text operator performs a full-text search using the analyzer that you specify in the index configuration. If you omit an analyzer, the text operator uses the default standard analyzer. arguments: - - - name: path - type: - - searchPath - - - name: query - type: - - string - - - name: fuzzy - optional: true - type: - - object - - - name: matchCriteria - optional: true - type: - - string # "any" | "all" - - - name: synonyms - optional: true - type: - - string - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: query + type: + - string + - name: fuzzy + optional: true + type: + - object + - name: matchCriteria + optional: true + type: + - string # "any" | "all" + - name: synonyms + optional: true + type: + - string + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Basic' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#basic-example' - pipeline: - - - $search: - text: - path: 'title' - query: 'surfer' - - - $project: - _id: 0 - title: 1 - score: - $meta: 'searchScore' - - - name: 'Fuzzy Default' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples' - pipeline: - - - $search: - text: - path: 'title' - query: 'naw yark' - fuzzy: {} - - - $limit: 10 - - - $project: - _id: 0 - title: 1 - score: - $meta: 'searchScore' - - - - name: 'Fuzzy maxExpansions' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples' - pipeline: - - - $search: - text: - path: 'title' - query: 'naw yark' - fuzzy: - maxEdits: 1 - maxExpansions: 100 - - - $limit: 10 - - - $project: - _id: 0 - title: 1 - score: - $meta: 'searchScore' - - - - name: 'Fuzzy prefixLength' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples' - pipeline: - - - $search: - text: - path: 'title' - query: 'naw yark' - fuzzy: - maxEdits: 1 - prefixLength: 2 - - - $limit: 8 - - - $project: - _id: 1 - title: 1 - score: - $meta: 'searchScore' - - - - 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' - - - $limit: 5 - - - $project: - _id: 0 - plot: 1 - title: 1 - score: - $meta: 'searchScore' - - - - 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' - - - $limit: 10 - - - $project: - _id: 0 - plot: 1 - title: 1 - score: - $meta: 'searchScore' - - - - 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' - - - $limit: 20 - - - $project: - _id: 0 - plot: 1 - title: 1 - score: - $meta: 'searchScore' - - - - name: 'Wildcard Path' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/' - pipeline: - - - $search: - text: - path: - wildcard: '*' - query: 'surfer' - - - $project: - _id: 0 - title: 1 - score: - $meta: 'searchScore' + - name: Basic + link: https://www.mongodb.com/docs/atlas/atlas-search/text/#basic-example + pipeline: + - $search: + text: + path: title + query: surfer + - $project: + _id: 0 + title: 1 + score: + $meta: searchScore + - name: Fuzzy Default + link: https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples + pipeline: + - $search: + text: + path: title + query: naw yark + fuzzy: {} + - $limit: 10 + - $project: + _id: 0 + title: 1 + score: + $meta: searchScore + - name: Fuzzy maxExpansions + link: https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples + pipeline: + - $search: + text: + path: title + query: naw yark + fuzzy: + maxEdits: 1 + maxExpansions: 100 + - $limit: 10 + - $project: + _id: 0 + title: 1 + score: + $meta: searchScore + - name: Fuzzy prefixLength + link: https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples + pipeline: + - $search: + text: + path: title + query: naw yark + fuzzy: + maxEdits: 1 + prefixLength: 2 + - $limit: 8 + - $project: + _id: 1 + title: 1 + score: + $meta: searchScore + - 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 + - $limit: 5 + - $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: searchScore + - 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 + - $limit: 10 + - $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: searchScore + - 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 + - $limit: 20 + - $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: searchScore + - name: Wildcard Path + link: https://www.mongodb.com/docs/atlas/atlas-search/text/ + pipeline: + - $search: + text: + path: + wildcard: '*' + query: surfer + - $project: + _id: 0 + title: 1 + score: + $meta: searchScore diff --git a/generator/config/search/wildcard.yaml b/generator/config/search/wildcard.yaml index d17fb4803..e6b346d83 100644 --- a/generator/config/search/wildcard.yaml +++ b/generator/config/search/wildcard.yaml @@ -1,60 +1,47 @@ # $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 description: | The wildcard operator enables queries which use special characters in the search string that can match any character. arguments: - - - name: path - type: - - searchPath - - - name: query - type: - - string - - - name: allowAnalyzedField - optional: true - type: - - bool - - - name: score - optional: true - type: - - searchScore + - name: path + type: + - searchPath + - name: query + type: + - string + - name: allowAnalyzedField + optional: true + type: + - bool + - name: score + optional: true + type: + - searchScore tests: - - - name: 'Wildcard Path' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/wildcard/#index-definition' - pipeline: - - - $search: - wildcard: - query: 'Wom?n *' - path: - wildcard: '*' - - - $limit: 5 - - - $project: - _id: 0 - title: 1 - - - - name: 'Escape Character Example' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/wildcard/#escape-character-example' - pipeline: - - - $search: - wildcard: - query: '*\?' - path: 'title' - - - $limit: 5 - - - $project: - _id: 0 - title: 1 + - name: Wildcard Path + link: https://www.mongodb.com/docs/atlas/atlas-search/wildcard/#index-definition + pipeline: + - $search: + wildcard: + query: Wom?n * + path: + wildcard: '*' + - $limit: 5 + - $project: + _id: 0 + title: 1 + - name: Escape Character Example + link: https://www.mongodb.com/docs/atlas/atlas-search/wildcard/#escape-character-example + pipeline: + - $search: + wildcard: + query: '*\?' + path: title + - $limit: 5 + - $project: + _id: 0 + title: 1 diff --git a/generator/config/stage/addFields.yaml b/generator/config/stage/addFields.yaml index e98f5de18..390a5c31b 100644 --- a/generator/config/stage/addFields.yaml +++ b/generator/config/stage/addFields.yaml @@ -1,64 +1,55 @@ # $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 description: | Adds new fields to documents. Outputs documents that contain all existing fields from the input documents and newly added fields. arguments: - - - name: expression - type: - - expression - variadic: object - description: | - Specify the name of each field to add and set its value to an aggregation expression or an empty object. + - name: expression + type: + - expression + variadic: object + description: | + 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' - pipeline: - - - $addFields: - totalHomework: + - 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'] - totalQuiz: + $sum: + - $homework + totalQuiz: # $sum: '$quiz' - $sum: ['$quiz'] - - - $addFields: - totalScore: - $add: - - '$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' - pipeline: - - - $addFields: - specs.fuel_type: 'unleaded' - - - 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' - pipeline: - - - $match: - _id: 1 - - - $addFields: - homework: - $concatArrays: - - '$homework' - - [7] + $sum: + - $quiz + - $addFields: + totalScore: + $add: + - $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 + pipeline: + - $addFields: + specs.fuel_type: unleaded + - 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 + pipeline: + - $match: + _id: 1 + - $addFields: + homework: + $concatArrays: + - $homework + - [7] diff --git a/generator/config/stage/bucket.yaml b/generator/config/stage/bucket.yaml index 0cd65feac..1cbf83246 100644 --- a/generator/config/stage/bucket.yaml +++ b/generator/config/stage/bucket.yaml @@ -1,101 +1,102 @@ # $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 description: | Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries. arguments: - - - name: groupBy - type: - - expression # mainly fieldPath - 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 - 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: - - - name: default - type: - - expression - optional: true - description: | - A literal that specifies the _id of an additional bucket that contains all documents whose groupBy expression result does not fall into a bucket specified by boundaries. - If unspecified, each input document must resolve the groupBy expression to a value within one of the bucket ranges specified by boundaries or the operation throws an error. - The default value must be less than the lowest boundaries value, or greater than or equal to the highest boundaries value. - The default value can be of a different type than the entries in boundaries. - - - name: output - type: - - object # of Accumulator - 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. - If you do not specify an output document, the operation returns a count field containing the number of documents in each bucket. - 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. + - name: groupBy + type: + - expression # mainly fieldPath + 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 + 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: + - name: default + type: + - expression + optional: true + description: | + A literal that specifies the _id of an additional bucket that contains all documents whose groupBy expression result does not fall into a bucket specified by boundaries. + If unspecified, each input document must resolve the groupBy expression to a value within one of the bucket ranges specified by boundaries or the operation throws an error. + The default value must be less than the lowest boundaries value, or greater than or equal to the highest boundaries value. + The default value can be of a different type than the entries in boundaries. + - name: output + type: + - object # of Accumulator + 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. + If you do not specify an output document, the operation returns a count field containing the number of documents in each bucket. + 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' - pipeline: - - - $bucket: - groupBy: '$year_born' - boundaries: [1840, 1850, 1860, 1870, 1880] - default: 'Other' - output: - count: - $sum: 1 - artists: - $push: - name: - $concat: - - '$first_name' - - ' ' - - '$last_name' - year_born: '$year_born' - - - $match: + - 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 + output: 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' - pipeline: - - - $facet: - price: - - - $bucket: - groupBy: '$price' - boundaries: [0, 200, 400] - default: 'Other' - output: - count: - $sum: 1 - artwork: - $push: - title: '$title' - price: '$price' - averagePrice: - $avg: '$price' - year: - - - $bucket: - groupBy: '$year' - boundaries: [1890, 1910, 1920, 1940] - default: 'Unknown' - output: - count: - $sum: 1 - artwork: - $push: - title: '$title' - year: '$year' + $sum: 1 + artists: + $push: + name: + $concat: + - $first_name + - ' ' + - $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 + pipeline: + - $facet: + price: + - $bucket: + groupBy: $price + boundaries: + - 0 + - 200 + - 400 + default: Other + output: + count: + $sum: 1 + artwork: + $push: + title: $title + price: $price + averagePrice: + $avg: $price + year: + - $bucket: + groupBy: $year + boundaries: + - 1890 + - 1910 + - 1920 + - 1940 + default: Unknown + output: + count: + $sum: 1 + artwork: + $push: + title: $title + year: $year diff --git a/generator/config/stage/bucketAuto.yaml b/generator/config/stage/bucketAuto.yaml index 73775fde8..f0c993bc1 100644 --- a/generator/config/stage/bucketAuto.yaml +++ b/generator/config/stage/bucketAuto.yaml @@ -1,46 +1,40 @@ # $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 description: | Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression. Bucket boundaries are automatically determined in an attempt to evenly distribute the documents into the specified number of buckets. arguments: - - - name: groupBy - type: - - 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. - - - name: buckets - type: - - int - description: | - A positive 32-bit integer that specifies the number of buckets into which input documents are grouped. - - - name: output - type: - - object # of Accumulator - 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. - The default count field is not included in the output document when output is specified. Explicitly specify the count expression as part of the output document to include it. - - - name: granularity - type: - - granularity - optional: true - description: | - A string that specifies the preferred number series to use to ensure that the calculated boundary edges end on preferred round numbers or their powers of 10. - Available only if the all groupBy values are numeric and none of them are NaN. + - name: groupBy + type: + - 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. + - name: buckets + type: + - int + description: | + A positive 32-bit integer that specifies the number of buckets into which input documents are grouped. + - name: output + type: + - object # of Accumulator + 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. + The default count field is not included in the output document when output is specified. Explicitly specify the count expression as part of the output document to include it. + - name: granularity + type: + - granularity + optional: true + description: | + A string that specifies the preferred number series to use to ensure that the calculated boundary edges end on preferred round numbers or their powers of 10. + 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' - pipeline: - - - $bucketAuto: - groupBy: '$price' - buckets: 4 + - name: Single Facet Aggregation + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucketAuto/#single-facet-aggregation + pipeline: + - $bucketAuto: + groupBy: $price + buckets: 4 diff --git a/generator/config/stage/changeStream.yaml b/generator/config/stage/changeStream.yaml index be413ef5d..fd38c484c 100644 --- a/generator/config/stage/changeStream.yaml +++ b/generator/config/stage/changeStream.yaml @@ -1,66 +1,57 @@ # $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 description: | Returns a Change Stream cursor for the collection or database. This stage can only occur once in an aggregation pipeline and it must occur as the first stage. arguments: - - - name: allChangesForCluster - type: - - bool - optional: true - description: | - A flag indicating whether the stream should report all changes that occur on the deployment, aside from those on internal databases or collections. - - - name: fullDocument - type: - - fullDocument - optional: true - description: | - Specifies whether change notifications include a copy of the full document when modified by update operations. - - - name: fullDocumentBeforeChange - type: - - fullDocumentBeforeChange - optional: true - description: | - Valid values are "off", "whenAvailable", or "required". If set to "off", the "fullDocumentBeforeChange" field of the output document is always omitted. If set to "whenAvailable", the "fullDocumentBeforeChange" field will be populated with the pre-image of the document modified by the current change event if such a pre-image is available, and will be omitted otherwise. If set to "required", then the "fullDocumentBeforeChange" field is always populated and an exception is thrown if the pre-image is not available. - - - name: resumeAfter - type: - - int - optional: true - description: | - Specifies a resume token as the logical starting point for the change stream. Cannot be used with startAfter or startAtOperationTime fields. - - - name: showExpandedEvents - type: - - bool - optional: true - description: | - Specifies whether to include additional change events, such as such as DDL and index operations. - New in MongoDB 6.0. - - - name: startAfter - type: - - object - optional: true - description: | - Specifies a resume token as the logical starting point for the change stream. Cannot be used with resumeAfter or startAtOperationTime fields. - - - name: startAtOperationTime - type: - - timestamp - optional: true - description: | - Specifies a time as the logical starting point for the change stream. Cannot be used with resumeAfter or startAfter fields. + - name: allChangesForCluster + type: + - bool + optional: true + description: | + A flag indicating whether the stream should report all changes that occur on the deployment, aside from those on internal databases or collections. + - name: fullDocument + type: + - fullDocument + optional: true + description: | + Specifies whether change notifications include a copy of the full document when modified by update operations. + - name: fullDocumentBeforeChange + type: + - fullDocumentBeforeChange + optional: true + description: | + Valid values are "off", "whenAvailable", or "required". If set to "off", the "fullDocumentBeforeChange" field of the output document is always omitted. If set to "whenAvailable", the "fullDocumentBeforeChange" field will be populated with the pre-image of the document modified by the current change event if such a pre-image is available, and will be omitted otherwise. If set to "required", then the "fullDocumentBeforeChange" field is always populated and an exception is thrown if the pre-image is not available. + - name: resumeAfter + type: + - int + optional: true + description: | + Specifies a resume token as the logical starting point for the change stream. Cannot be used with startAfter or startAtOperationTime fields. + - name: showExpandedEvents + type: + - bool + optional: true + description: | + Specifies whether to include additional change events, such as such as DDL and index operations. + New in MongoDB 6.0. + - name: startAfter + type: + - object + optional: true + description: | + Specifies a resume token as the logical starting point for the change stream. Cannot be used with resumeAfter or startAtOperationTime fields. + - name: startAtOperationTime + type: + - timestamp + optional: true + description: | + 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' - pipeline: - - - $changeStream: {} + - 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..d44451dd1 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 @@ -8,9 +8,7 @@ description: | Splits large change stream events that exceed 16 MB into smaller fragments returned in a change stream cursor. 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' - pipeline: - - - $changeStreamSplitLargeEvent: {} + - 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..b11939e01 100644 --- a/generator/config/stage/collStats.yaml +++ b/generator/config/stage/collStats.yaml @@ -1,59 +1,47 @@ # $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 description: | Returns statistics regarding a collection or view. arguments: - - - name: latencyStats - type: - - object - optional: true - - - name: storageStats - type: - - object - optional: true - - - name: count - type: - - object # empty object - optional: true - - - name: queryExecStats - type: - - object # empty object - optional: true + - name: latencyStats + type: + - object + optional: true + - name: storageStats + type: + - object + optional: true + - name: count + type: + - object # empty object + optional: true + - name: queryExecStats + type: + - object # empty object + optional: true tests: - - - 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' - pipeline: - - - $collStats: - storageStats: {} - - - 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' - pipeline: - - - $collStats: - queryExecStats: {} + - 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 + pipeline: + - $collStats: + storageStats: {} + - 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 + pipeline: + - $collStats: + queryExecStats: {} diff --git a/generator/config/stage/count.yaml b/generator/config/stage/count.yaml index a0fa3ba57..9774878e5 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 @@ -8,20 +8,16 @@ description: | Returns a count of the number of documents at this stage of the aggregation pipeline. Distinct from the $count aggregation accumulator. arguments: - - - name: field - type: - - string - description: | - 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. + - name: field + type: + - string + description: | + 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' - pipeline: - - - $match: - score: - $gt: 80 - - - $count: 'passing_scores' + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/#example + pipeline: + - $match: + score: + $gt: 80 + - $count: passing_scores diff --git a/generator/config/stage/currentOp.yaml b/generator/config/stage/currentOp.yaml index 024c71318..62cf3c2a9 100644 --- a/generator/config/stage/currentOp.yaml +++ b/generator/config/stage/currentOp.yaml @@ -1,59 +1,48 @@ # $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 description: | Returns information on active and/or dormant operations for the MongoDB deployment. To run, use the db.aggregate() method. arguments: - - - name: allUsers - type: - - bool - optional: true - - - name: idleConnections - type: - - bool - optional: true - - - name: idleCursors - type: - - bool - optional: true - - - name: idleSessions - type: - - bool - optional: true - - - name: localOps - type: - - bool - optional: true + - name: allUsers + type: + - bool + optional: true + - name: idleConnections + type: + - bool + optional: true + - name: idleCursors + type: + - bool + optional: true + - name: idleSessions + type: + - bool + optional: true + - name: localOps + type: + - bool + optional: true tests: - - - name: 'Inactive Sessions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/#inactive-sessions' - pipeline: - - - $currentOp: - allUsers: true - idleSessions: true - - - $match: - active: false - transaction: - $exists: true - - - name: 'Sampled Queries' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/#sampled-queries' - pipeline: - - - $currentOp: - allUsers: true - localOps: true - - - $match: - desc: 'query analyzer' + - name: Inactive Sessions + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/#inactive-sessions + pipeline: + - $currentOp: + allUsers: true + idleSessions: true + - $match: + active: false + transaction: + $exists: true + - name: Sampled Queries + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/#sampled-queries + pipeline: + - $currentOp: + allUsers: true + localOps: true + - $match: + desc: query analyzer diff --git a/generator/config/stage/densify.yaml b/generator/config/stage/densify.yaml index 46ccbd6dd..31dd19a3b 100644 --- a/generator/config/stage/densify.yaml +++ b/generator/config/stage/densify.yaml @@ -1,56 +1,49 @@ # $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 description: | Creates new documents in a sequence of documents where certain values in a field are missing. arguments: - - - name: field - type: - - string # field name - 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. - To specify a in an embedded document or in an array, use dot notation. - - - name: partitionByFields - type: - - array # of string - optional: true - description: | - The field(s) that will be used as the partition keys. - - - name: range - type: - - range - description: | - Specification for range based densification. + - name: field + type: + - string # field name + 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. + To specify a in an embedded document or in an array, use dot notation. + - name: partitionByFields + type: + - array # of string + optional: true + description: | + The field(s) that will be used as the partition keys. + - name: range + type: + - range + description: | + 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' - pipeline: - - - $densify: - field: 'timestamp' - range: - step: 1 - unit: 'hour' - bounds: - - !bson_utcdatetime '2021-05-18T00:00:00.000Z' - - !bson_utcdatetime '2021-05-18T08:00:00.000Z' - - - name: 'Densifiction with Partitions' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/#densifiction-with-partitions' - pipeline: - - - $densify: - field: 'altitude' - partitionByFields: - - 'variety' - range: - bounds: 'full' - step: 200 + - name: Densify Time Series Data + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/#densify-time-series-data + pipeline: + - $densify: + field: timestamp + range: + step: 1 + unit: hour + bounds: + - !bson_utcdatetime '2021-05-18T00:00:00.000Z' + - !bson_utcdatetime '2021-05-18T08:00:00.000Z' + - name: Densifiction with Partitions + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/#densifiction-with-partitions + pipeline: + - $densify: + field: altitude + partitionByFields: + - variety + range: + bounds: full + step: 200 diff --git a/generator/config/stage/documents.yaml b/generator/config/stage/documents.yaml index 666468da8..a41816d7a 100644 --- a/generator/config/stage/documents.yaml +++ b/generator/config/stage/documents.yaml @@ -1,53 +1,43 @@ # $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 description: | Returns literal documents from input values. arguments: - - - name: documents - type: - - resolvesToArray # of object - description: | - $documents accepts any valid expression that resolves to an array of objects. This includes: - - system variables, such as $$NOW or $$SEARCH_META - - $let expressions - - variables in scope from $lookup expressions - Expressions that do not resolve to a current document, like $myField or $$ROOT, will result in an error. + - name: documents + type: + - resolvesToArray # of object + description: | + $documents accepts any valid expression that resolves to an array of objects. This includes: + - system variables, such as $$NOW or $$SEARCH_META + - $let expressions + - variables in scope from $lookup expressions + 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' - pipeline: - - - $documents: - - { x: 10 } - - { x: 2 } - - { x: 5 } - - - $bucketAuto: - 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' - pipeline: - - - $match: {} - - - $lookup: - localField: 'zip' - foreignField: 'zip_id' - as: 'city_state' - pipeline: - - - $documents: - - - zip_id: 94301 - name: 'Palo Alto, CA' - - - zip_id: 10019 - name: 'New York, NY' + - 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} + - $bucketAuto: + 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 + pipeline: + - $match: {} + - $lookup: + localField: zip + foreignField: zip_id + as: city_state + pipeline: + - $documents: + - zip_id: 94301 + name: Palo Alto, CA + - zip_id: 10019 + name: New York, NY diff --git a/generator/config/stage/facet.yaml b/generator/config/stage/facet.yaml index 013163c2a..df33b8dc5 100644 --- a/generator/config/stage/facet.yaml +++ b/generator/config/stage/facet.yaml @@ -1,51 +1,48 @@ # $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 description: | Processes multiple aggregation pipelines within a single stage on the same set of input documents. Enables the creation of multi-faceted aggregations capable of characterizing data across multiple dimensions, or facets, in a single stage. arguments: - - - name: facet - type: - - pipeline - variadic: object + - name: facet + type: + - pipeline + variadic: object tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/#example' - pipeline: - - - $facet: - categorizedByTags: - - + - 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' - - - $sortByCount: '$tags' - categorizedByPrice: - - - $match: - price: + - $unwind: + path: $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' - output: - count: - $sum: 1 - titles: - $push: '$title' - categorizedByYears(Auto): - - - $bucketAuto: - groupBy: '$year' - buckets: 4 + $exists: true + - $bucket: + groupBy: $price + boundaries: + - 0 + - 150 + - 200 + - 300 + - 400 + default: Other + output: + count: + $sum: 1 + titles: + $push: $title + categorizedByYears(Auto): + - $bucketAuto: + groupBy: $year + buckets: 4 diff --git a/generator/config/stage/fill.yaml b/generator/config/stage/fill.yaml index 2c98fac5c..352cf83cf 100644 --- a/generator/config/stage/fill.yaml +++ b/generator/config/stage/fill.yaml @@ -1,110 +1,94 @@ # $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 description: | Populates null and missing field values within documents. arguments: - - - name: partitionBy - type: - - object # of expression - - string - optional: true - description: | - Specifies an expression to group the documents. In the $fill stage, a group of documents is known as a partition. - If you omit partitionBy and partitionByFields, $fill uses one partition for the entire collection. - partitionBy and partitionByFields are mutually exclusive. - - - name: partitionByFields - type: - - array # of string - 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. - If you omit partitionBy and partitionByFields, $fill uses one partition for the entire collection. - partitionBy and partitionByFields are mutually exclusive. - - - name: sortBy - type: - - sortBy - optional: true - description: | - Specifies the field or fields to sort the documents within each partition. Uses the same syntax as the $sort stage. - - - name: output - type: - - object # of object{value:expression} or object{method:string}> - 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. + - name: partitionBy + type: + - object # of expression + - string + optional: true + description: | + Specifies an expression to group the documents. In the $fill stage, a group of documents is known as a partition. + If you omit partitionBy and partitionByFields, $fill uses one partition for the entire collection. + partitionBy and partitionByFields are mutually exclusive. + - name: partitionByFields + type: + - array # of string + 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. + If you omit partitionBy and partitionByFields, $fill uses one partition for the entire collection. + partitionBy and partitionByFields are mutually exclusive. + - name: sortBy + type: + - sortBy + optional: true + description: | + Specifies the field or fields to sort the documents within each partition. Uses the same syntax as the $sort stage. + - name: output + type: + - object # of object{value:expression} or object{method:string}> + 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' - pipeline: - - - $fill: - output: - bootsSold: - value: 0 - sandalsSold: - value: 0 - 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' - pipeline: - - - $fill: - sortBy: - time: 1 - output: - price: - 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' - pipeline: - - - $fill: - sortBy: - date: 1 - output: - score: - method: 'locf' - - - 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' - output: - score: - 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' - pipeline: - - - $set: - valueExisted: - $ifNull: - - - $toBool: - $toString: '$score' - - false - - - $fill: - sortBy: - date: 1 - output: - score: - method: 'locf' + - 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: + output: + bootsSold: + value: 0 + sandalsSold: + value: 0 + 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 + pipeline: + - $fill: + sortBy: + time: 1 + output: + price: + 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 + pipeline: + - $fill: + sortBy: + date: 1 + output: + score: + method: locf + - 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 + output: + score: + 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 + pipeline: + - $set: + valueExisted: + $ifNull: + - $toBool: + $toString: $score + - false + - $fill: + sortBy: + date: 1 + output: + score: + method: locf diff --git a/generator/config/stage/geoNear.yaml b/generator/config/stage/geoNear.yaml index 4967a0823..f32cd47dc 100644 --- a/generator/config/stage/geoNear.yaml +++ b/generator/config/stage/geoNear.yaml @@ -1,161 +1,139 @@ # $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 description: | Returns an ordered stream of documents based on the proximity to a geospatial point. Incorporates the functionality of $match, $sort, and $limit for geospatial data. The output documents include an additional distance field and can include a location identifier field. arguments: - - - name: distanceField - type: - - string - optional: true - description: | - The output field that contains the calculated distance. To specify a field within an embedded document, use dot notation. - - - name: distanceMultiplier - type: - - number - optional: true - description: | - The factor to multiply all distances returned by the query. For example, use the distanceMultiplier to convert radians, as returned by a spherical query, to kilometers by multiplying by the radius of the Earth. - - - name: includeLocs - type: - - string - optional: true - description: | - This specifies the output field that identifies the location used to calculate the distance. This option is useful when a location field contains multiple locations. To specify a field within an embedded document, use dot notation. - - - name: key - type: - - string - optional: true - description: | - Specify the geospatial indexed field to use when calculating the distance. - - - name: maxDistance - type: - - number - optional: true - description: | - The maximum distance from the center point that the documents can be. MongoDB limits the results to those documents that fall within the specified distance from the center point. - Specify the distance in meters if the specified point is GeoJSON and in radians if the specified point is legacy coordinate pairs. - - - name: minDistance - type: - - number - optional: true - description: | - The minimum distance from the center point that the documents can be. MongoDB limits the results to those documents that fall outside the specified distance from the center point. - Specify the distance in meters for GeoJSON data and in radians for legacy coordinate pairs. - - - name: near - type: - - geoPoint - - resolvesToObject - description: | - The point for which to find the closest documents. - - - name: query - type: - - query - optional: true - description: | - Limits the results to the documents that match the query. The query syntax is the usual MongoDB read operation query syntax. - You cannot specify a $near predicate in the query field of the $geoNear stage. - - - name: spherical - type: - - bool - optional: true - description: | - Determines how MongoDB calculates the distance between two points: - - When true, MongoDB uses $nearSphere semantics and calculates distances using spherical geometry. - - When false, MongoDB uses $near semantics: spherical geometry for 2dsphere indexes and planar geometry for 2d indexes. - Default: false. + - name: distanceField + type: + - string + optional: true + description: | + The output field that contains the calculated distance. To specify a field within an embedded document, use dot notation. + - name: distanceMultiplier + type: + - number + optional: true + description: | + The factor to multiply all distances returned by the query. For example, use the distanceMultiplier to convert radians, as returned by a spherical query, to kilometers by multiplying by the radius of the Earth. + - name: includeLocs + type: + - string + optional: true + description: | + This specifies the output field that identifies the location used to calculate the distance. This option is useful when a location field contains multiple locations. To specify a field within an embedded document, use dot notation. + - name: key + type: + - string + optional: true + description: | + Specify the geospatial indexed field to use when calculating the distance. + - name: maxDistance + type: + - number + optional: true + description: | + The maximum distance from the center point that the documents can be. MongoDB limits the results to those documents that fall within the specified distance from the center point. + Specify the distance in meters if the specified point is GeoJSON and in radians if the specified point is legacy coordinate pairs. + - name: minDistance + type: + - number + optional: true + description: | + The minimum distance from the center point that the documents can be. MongoDB limits the results to those documents that fall outside the specified distance from the center point. + Specify the distance in meters for GeoJSON data and in radians for legacy coordinate pairs. + - name: near + type: + - geoPoint + - resolvesToObject + description: | + The point for which to find the closest documents. + - name: query + type: + - query + optional: true + description: | + Limits the results to the documents that match the query. The query syntax is the usual MongoDB read operation query syntax. + You cannot specify a $near predicate in the query field of the $geoNear stage. + - name: spherical + type: + - bool + optional: true + description: | + Determines how MongoDB calculates the distance between two points: + - When true, MongoDB uses $nearSphere semantics and calculates distances using spherical geometry. + - When false, MongoDB uses $near semantics: spherical geometry for 2dsphere indexes and planar geometry for 2d indexes. + Default: false. tests: - - - name: 'Maximum Distance' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#maximum-distance' - pipeline: - - - $geoNear: - near: - type: 'Point' - coordinates: - - -73.99279 - - 40.719296 - distanceField: 'dist.calculated' - maxDistance: 2 - query: - category: 'Parks' - includeLocs: 'dist.location' - spherical: true - - - name: 'Minimum Distance' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#minimum-distance' - pipeline: - - - $geoNear: - near: - type: 'Point' - coordinates: - - -73.99279 - - 40.719296 - distanceField: 'dist.calculated' - minDistance: 2 - query: - 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' - pipeline: - - - $geoNear: - near: '$$pt' - distanceField: 'distance' - maxDistance: 2 - query: - 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' - pipeline: - - - $lookup: - from: 'places' - let: - pt: '$location' - pipeline: - - - $geoNear: - near: '$$pt' - distanceField: 'distance' - as: 'joinedField' - - - $match: - 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' - pipeline: - - - $geoNear: - near: - type: 'Point' - coordinates: - - -73.98142 - - 40.71782 - key: 'location' - distanceField: 'dist.calculated' - query: - category: 'Parks' - - - $limit: 5 + - name: Maximum Distance + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#maximum-distance + pipeline: + - $geoNear: + near: + type: Point + coordinates: + - -73.99279 + - 40.719296 + distanceField: dist.calculated + maxDistance: 2 + query: + category: Parks + includeLocs: dist.location + spherical: true + - name: Minimum Distance + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#minimum-distance + pipeline: + - $geoNear: + near: + type: Point + coordinates: + - -73.99279 + - 40.719296 + distanceField: dist.calculated + minDistance: 2 + query: + 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 + pipeline: + - $geoNear: + near: $$pt + distanceField: distance + maxDistance: 2 + query: + 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 + pipeline: + - $lookup: + from: places + let: + pt: $location + pipeline: + - $geoNear: + near: $$pt + distanceField: distance + as: joinedField + - $match: + 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 + pipeline: + - $geoNear: + near: + type: Point + coordinates: + - -73.98142 + - 40.71782 + key: location + distanceField: dist.calculated + query: + category: Parks + - $limit: 5 diff --git a/generator/config/stage/graphLookup.yaml b/generator/config/stage/graphLookup.yaml index ae220620b..626b1ec39 100644 --- a/generator/config/stage/graphLookup.yaml +++ b/generator/config/stage/graphLookup.yaml @@ -1,108 +1,92 @@ # $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 description: | Performs a recursive search on a collection. To each output document, adds a new array field that contains the traversal results of the recursive search for that document. arguments: - - - name: from - type: - - string - description: | - Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField. The from collection must be in the same database as any other collections used in the operation. - Starting in MongoDB 5.1, the collection specified in the from parameter can be sharded. - - - name: startWith - type: - - expression - - array - description: | - Expression that specifies the value of the connectFromField with which to start the recursive search. Optionally, startWith may be array of values, each of which is individually followed through the traversal process. - - - name: connectFromField - type: - - string - description: | - Field name whose value $graphLookup uses to recursively match against the connectToField of other documents in the collection. If the value is an array, each element is individually followed through the traversal process. - - - name: connectToField - type: - - string - description: | - Field name in other documents against which to match the value of the field specified by the connectFromField parameter. - - - name: as - type: - - string - description: | - Name of the array field added to each output document. Contains the documents traversed in the $graphLookup stage to reach the document. - - - name: maxDepth - type: - - int - optional: true - description: | - Non-negative integral number specifying the maximum recursion depth. - - - name: depthField - type: - - string - optional: true - description: | - Name of the field to add to each traversed document in the search path. The value of this field is the recursion depth for the document, represented as a NumberLong. Recursion depth value starts at zero, so the first lookup corresponds to zero depth. - - - name: restrictSearchWithMatch - type: - - query - optional: true - description: | - A document specifying additional conditions for the recursive search. The syntax is identical to query filter syntax. + - name: from + type: + - string + description: | + Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField. The from collection must be in the same database as any other collections used in the operation. + Starting in MongoDB 5.1, the collection specified in the from parameter can be sharded. + - name: startWith + type: + - expression + - array + description: | + Expression that specifies the value of the connectFromField with which to start the recursive search. Optionally, startWith may be array of values, each of which is individually followed through the traversal process. + - name: connectFromField + type: + - string + description: | + Field name whose value $graphLookup uses to recursively match against the connectToField of other documents in the collection. If the value is an array, each element is individually followed through the traversal process. + - name: connectToField + type: + - string + description: | + Field name in other documents against which to match the value of the field specified by the connectFromField parameter. + - name: as + type: + - string + description: | + Name of the array field added to each output document. Contains the documents traversed in the $graphLookup stage to reach the document. + - name: maxDepth + type: + - int + optional: true + description: | + Non-negative integral number specifying the maximum recursion depth. + - name: depthField + type: + - string + optional: true + description: | + Name of the field to add to each traversed document in the search path. The value of this field is the recursion depth for the document, represented as a NumberLong. Recursion depth value starts at zero, so the first lookup corresponds to zero depth. + - name: restrictSearchWithMatch + type: + - query + optional: true + description: | + 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' - pipeline: - - - $graphLookup: - 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' - pipeline: - - - $graphLookup: - from: 'airports' - startWith: '$nearestAirport' - connectFromField: 'connects' - connectToField: 'airport' - maxDepth: 2 - depthField: 'numConnections' - as: 'destinations' - - - 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' - - - $graphLookup: - from: 'people' - startWith: '$friends' - connectFromField: 'friends' - connectToField: 'name' - as: 'golfers' - restrictSearchWithMatch: - hobbies: 'golf' - - - $project: - name: 1 - friends: 1 - connections who play golf: '$golfers.name' + - 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 + - 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 + maxDepth: 2 + depthField: numConnections + as: destinations + - 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 + - $graphLookup: + from: people + startWith: $friends + connectFromField: friends + connectToField: name + as: golfers + restrictSearchWithMatch: + hobbies: golf + - $project: + name: 1 + friends: 1 + connections who play golf: $golfers.name diff --git a/generator/config/stage/group.yaml b/generator/config/stage/group.yaml index a4bae60c2..f6efe0ce1 100644 --- a/generator/config/stage/group.yaml +++ b/generator/config/stage/group.yaml @@ -1,123 +1,104 @@ # $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 description: | Groups input documents by a specified identifier expression and applies the accumulator expression(s), if specified, to each group. Consumes all input documents and outputs one document per each distinct group. The output documents only contain the identifier field and, if specified, accumulated fields. arguments: - - - name: _id - type: - - expression - description: | - The _id expression specifies the group key. If you specify an _id value of null, or any other constant value, the $group stage returns a single document that aggregates values across all of the input documents. - - - name: field - mergeObject: true - type: - - accumulator - variadic: object - variadicMin: 0 - description: | - Computed using the accumulator operators. + - name: _id + type: + - expression + description: | + The _id expression specifies the group key. If you specify an _id value of null, or any other constant value, the $group stage returns a single document that aggregates values across all of the input documents. + - name: field + mergeObject: true + type: + - accumulator + variadic: object + variadicMin: 0 + description: | + 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' - pipeline: - - - $group: - _id: ~ - count: - $count: {} - - - name: 'Retrieve Distinct Values' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#retrieve-distinct-values' - pipeline: - - - $group: - _id: '$item' - - - name: 'Group by Item Having' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-by-item-having' - pipeline: - - - $group: - _id: '$item' - totalSaleAmount: - $sum: - $multiply: - - '$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' - pipeline: - - - $match: - date: - $gte: !bson_utcdatetime '2014-01-01' - $lt: !bson_utcdatetime '2015-01-01' - - - $group: - _id: - $dateToString: - format: '%Y-%m-%d' - date: '$date' - totalSaleAmount: - $sum: - $multiply: - - '$price' - - '$quantity' - averageQuantity: - $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' - pipeline: - - - $group: - _id: ~ - totalSaleAmount: - $sum: - $multiply: - - '$price' - - '$quantity' - averageQuantity: - $avg: '$quantity' - count: - $sum: 1 - - - name: 'Pivot Data' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#pivot-data' - pipeline: - - - $group: - _id: '$author' - books: - $push: '$title' - - - name: 'Group Documents by author' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-documents-by-author' - pipeline: - - - $group: - _id: '$author' - books: - $push: '$$ROOT' - - - $addFields: - totalCopies: + - 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: ~ + count: + $count: {} + - name: Retrieve Distinct Values + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#retrieve-distinct-values + pipeline: + - $group: + _id: $item + - name: Group by Item Having + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-by-item-having + pipeline: + - $group: + _id: $item + totalSaleAmount: + $sum: + $multiply: + - $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 + pipeline: + - $match: + date: + $gte: !bson_utcdatetime '2014-01-01' + $lt: !bson_utcdatetime '2015-01-01' + - $group: + _id: + $dateToString: + format: '%Y-%m-%d' + date: $date + totalSaleAmount: + $sum: + $multiply: + - $price + - $quantity + averageQuantity: + $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 + pipeline: + - $group: + _id: ~ + totalSaleAmount: + $sum: + $multiply: + - $price + - $quantity + averageQuantity: + $avg: $quantity + count: + $sum: 1 + - name: Pivot Data + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#pivot-data + pipeline: + - $group: + _id: $author + books: + $push: $title + - name: Group Documents by author + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-documents-by-author + pipeline: + - $group: + _id: $author + books: + $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..78a4f55df 100644 --- a/generator/config/stage/indexStats.yaml +++ b/generator/config/stage/indexStats.yaml @@ -1,15 +1,13 @@ # $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 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' - pipeline: - - - $indexStats: {} + - 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..cbb058284 100644 --- a/generator/config/stage/limit.yaml +++ b/generator/config/stage/limit.yaml @@ -1,20 +1,17 @@ # $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 description: | Passes the first n documents unmodified to the pipeline where n is the specified limit. For each input document, outputs either one document (for the first n documents) or zero documents (after the first n documents). arguments: - - - name: limit - type: - - int + - name: limit + type: + - int tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/#example' - pipeline: - - - $limit: 5 + - 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..88b23fa90 100644 --- a/generator/config/stage/listLocalSessions.yaml +++ b/generator/config/stage/listLocalSessions.yaml @@ -1,47 +1,38 @@ # $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 description: | Lists all active sessions recently in use on the currently connected mongos or mongod instance. These sessions may have not yet propagated to the system.sessions collection. arguments: - - - name: users - type: - - array - optional: true - description: | - Returns all sessions for the specified users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster to list sessions for other users. - - - name: allUsers - type: - - bool - optional: true - description: | - Returns all sessions for all users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster. + - name: users + type: + - array + optional: true + description: | + Returns all sessions for the specified users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster to list sessions for other users. + - name: allUsers + type: + - bool + optional: true + description: | + 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' - 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' - pipeline: - - - $listLocalSessions: - users: - - - 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' - pipeline: - - - $listLocalSessions: {} + - 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 + pipeline: + - $listLocalSessions: + users: + - 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 + pipeline: + - $listLocalSessions: {} diff --git a/generator/config/stage/listSampledQueries.yaml b/generator/config/stage/listSampledQueries.yaml index f767f0d04..f64ed8df3 100644 --- a/generator/config/stage/listSampledQueries.yaml +++ b/generator/config/stage/listSampledQueries.yaml @@ -1,29 +1,23 @@ # $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 description: | Lists sampled queries for all collections or a specific collection. arguments: - - - name: namespace - type: - - string - optional: true + - name: namespace + type: + - string + 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' - 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' - pipeline: - - - $listSampledQueries: - namespace: 'social.post' + - 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 + pipeline: + - $listSampledQueries: + namespace: social.post diff --git a/generator/config/stage/listSearchIndexes.yaml b/generator/config/stage/listSearchIndexes.yaml index afc4f6d05..a53f736e5 100644 --- a/generator/config/stage/listSearchIndexes.yaml +++ b/generator/config/stage/listSearchIndexes.yaml @@ -1,44 +1,36 @@ # $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 description: | Returns information about existing Atlas Search indexes on a specified collection. arguments: - - - name: id - type: - - string - optional: true - description: | - The id of the index to return information about. - - - name: name - type: - - string - optional: true - description: | - The name of the index to return information about. + - name: id + type: + - string + optional: true + description: | + The id of the index to return information about. + - name: name + type: + - string + optional: true + description: | + 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' - 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' - pipeline: - - - $listSearchIndexes: - 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' - pipeline: - - - $listSearchIndexes: - id: '6524096020da840844a4c4a7' + - 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 + pipeline: + - $listSearchIndexes: + 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 + pipeline: + - $listSearchIndexes: + id: 6524096020da840844a4c4a7 diff --git a/generator/config/stage/listSessions.yaml b/generator/config/stage/listSessions.yaml index efb56de05..5f020a7ab 100644 --- a/generator/config/stage/listSessions.yaml +++ b/generator/config/stage/listSessions.yaml @@ -1,48 +1,38 @@ # $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 description: | Lists all sessions that have been active long enough to propagate to the system.sessions collection. arguments: - - - name: users - type: - - array - optional: true - description: | - Returns all sessions for the specified users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster to list sessions for other users. - - - name: allUsers - type: - - bool - optional: true - description: | - Returns all sessions for all users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster. + - name: users + type: + - array + optional: true + description: | + Returns all sessions for the specified users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster to list sessions for other users. + - name: allUsers + type: + - bool + optional: true + description: | + 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' - 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' - pipeline: - - - $listSessions: - users: - - - 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' - pipeline: - - - $listSessions: {} - + - 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 + pipeline: + - $listSessions: + users: + - 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 + pipeline: + - $listSessions: {} diff --git a/generator/config/stage/lookup.yaml b/generator/config/stage/lookup.yaml index b73770e47..0771be1b6 100644 --- a/generator/config/stage/lookup.yaml +++ b/generator/config/stage/lookup.yaml @@ -1,165 +1,136 @@ # $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 description: | Performs a left outer join to another collection in the same database to filter in documents from the "joined" collection for processing. arguments: - - - name: from - type: - - string - optional: true - description: | - Specifies the collection in the same database to perform the join with. - from is optional, you can use a $documents stage in a $lookup stage instead. For an example, see Use a $documents Stage in a $lookup Stage. - Starting in MongoDB 5.1, the collection specified in the from parameter can be sharded. - - - name: localField - type: - - string - optional: true - description: | - Specifies the field from the documents input to the $lookup stage. $lookup performs an equality match on the localField to the foreignField from the documents of the from collection. If an input document does not contain the localField, the $lookup treats the field as having a value of null for matching purposes. - - - name: foreignField - type: - - string - optional: true - description: | - Specifies the field from the documents in the from collection. $lookup performs an equality match on the foreignField to the localField from the input documents. If a document in the from collection does not contain the foreignField, the $lookup treats the value as null for matching purposes. - - - name: let - type: - - object # of expression - 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. - - - name: pipeline - type: - - pipeline - optional: true - description: | - Specifies the pipeline to run on the joined collection. The pipeline determines the resulting documents from the joined collection. To return all documents, specify an empty pipeline []. - The pipeline cannot include the $out stage or the $merge stage. Starting in v6.0, the pipeline can contain the Atlas Search $search stage as the first stage inside the pipeline. - The pipeline cannot directly access the joined document fields. Instead, define variables for the joined document fields using the let option and then reference the variables in the pipeline stages. - - - name: as - type: - - string - description: | - 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. + - name: from + type: + - string + optional: true + description: | + Specifies the collection in the same database to perform the join with. + from is optional, you can use a $documents stage in a $lookup stage instead. For an example, see Use a $documents Stage in a $lookup Stage. + Starting in MongoDB 5.1, the collection specified in the from parameter can be sharded. + - name: localField + type: + - string + optional: true + description: | + Specifies the field from the documents input to the $lookup stage. $lookup performs an equality match on the localField to the foreignField from the documents of the from collection. If an input document does not contain the localField, the $lookup treats the field as having a value of null for matching purposes. + - name: foreignField + type: + - string + optional: true + description: | + Specifies the field from the documents in the from collection. $lookup performs an equality match on the foreignField to the localField from the input documents. If a document in the from collection does not contain the foreignField, the $lookup treats the value as null for matching purposes. + - name: let + type: + - object # of expression + 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. + - name: pipeline + type: + - pipeline + optional: true + description: | + Specifies the pipeline to run on the joined collection. The pipeline determines the resulting documents from the joined collection. To return all documents, specify an empty pipeline []. + The pipeline cannot include the $out stage or the $merge stage. Starting in v6.0, the pipeline can contain the Atlas Search $search stage as the first stage inside the pipeline. + The pipeline cannot directly access the joined document fields. Instead, define variables for the joined document fields using the let option and then reference the variables in the pipeline stages. + - name: as + type: + - string + description: | + 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' - pipeline: - - - $lookup: - 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' - pipeline: - - - $lookup: - 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' - pipeline: - - - $lookup: - from: 'items' - localField: 'item' - foreignField: 'item' - as: 'fromItems' - - - $replaceRoot: - newRoot: - $mergeObjects: - - - $arrayElemAt: - - '$fromItems' - - 0 - - '$$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' - pipeline: - - - $lookup: - from: 'warehouses' - let: - order_item: '$item' - order_qty: '$ordered' - pipeline: - - - $match: - $expr: - $and: - - - $eq: - - '$stock_item' - - '$$order_item' - - - $gte: - - '$instock' - - '$$order_qty' - - - $project: - stock_item: 0 - _id: 0 - 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' - pipeline: - - - $lookup: - from: 'holidays' - pipeline: - - - $match: - year: 2018 - - - $project: - _id: 0 - date: - name: '$name' - date: '$date' - - - $replaceRoot: - 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' - pipeline: - - - $lookup: - from: 'restaurants' - localField: 'restaurant_name' - foreignField: 'name' - let: - orders_drink: '$drink' - pipeline: - - - $match: - $expr: - $in: - - '$$orders_drink' - - '$beverages' - as: 'matches' + - 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 + - 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 + - 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 + - $replaceRoot: + newRoot: + $mergeObjects: + - $arrayElemAt: + - $fromItems + - 0 + - $$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 + pipeline: + - $lookup: + from: warehouses + let: + order_item: $item + order_qty: $ordered + pipeline: + - $match: + $expr: + $and: + - $eq: + - $stock_item + - $$order_item + - $gte: + - $instock + - $$order_qty + - $project: + stock_item: 0 + _id: 0 + 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 + pipeline: + - $lookup: + from: holidays + pipeline: + - $match: + year: 2018 + - $project: + _id: 0 + date: + name: $name + date: $date + - $replaceRoot: + 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 + pipeline: + - $lookup: + from: restaurants + localField: restaurant_name + foreignField: name + let: + orders_drink: $drink + pipeline: + - $match: + $expr: + $in: + - $$orders_drink + - $beverages + as: matches diff --git a/generator/config/stage/match.yaml b/generator/config/stage/match.yaml index ab0081fd0..417f88995 100644 --- a/generator/config/stage/match.yaml +++ b/generator/config/stage/match.yaml @@ -1,40 +1,32 @@ # $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 description: | Filters the document stream to allow only matching documents to pass unmodified into the next pipeline stage. $match uses standard MongoDB queries. For each input document, outputs either one document (a match) or zero documents (no match). arguments: - - - name: query - type: - - query + - name: query + type: + - query tests: - - - name: 'Equality Match' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/#equality-match' - pipeline: - - - $match: - author: 'dave' - - - name: 'Perform a Count' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/#perform-a-count' - pipeline: - - - $match: - $or: - - - score: - $gt: 70 - $lt: 90 - - - views: - $gte: 1000 - - - $group: - _id: ~ - count: - $sum: 1 + - name: Equality Match + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/#equality-match + pipeline: + - $match: + author: dave + - name: Perform a Count + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/#perform-a-count + pipeline: + - $match: + $or: + - score: + $gt: 70 + $lt: 90 + - views: + $gte: 1000 + - $group: + _id: ~ + count: + $sum: 1 diff --git a/generator/config/stage/merge.yaml b/generator/config/stage/merge.yaml index 766092d82..44b65696e 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 @@ -8,173 +8,145 @@ description: | Writes the resulting documents of the aggregation pipeline to a collection. The stage can incorporate (insert new documents, merge documents, replace documents, keep existing documents, fail the operation, process documents with a custom update pipeline) the results into an output collection. To use the $merge stage, it must be the last stage in the pipeline. New in MongoDB 4.2. arguments: - - - name: into - type: - - string - - outCollection - description: | - The output collection. - - - name: 'on' - type: - - string - - array # of string - 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. - - - name: let - type: - - object - optional: true - description: | - Specifies variables for use in the whenMatched pipeline. - - - name: whenMatched - type: - - whenMatched - - pipeline - optional: true - description: | - The behavior of $merge if a result document and an existing document in the collection have the same value for the specified on field(s). - - - name: whenNotMatched - type: - - whenNotMatched - optional: true - description: | - The behavior of $merge if a result document does not match an existing document in the out collection. + - name: into + type: + - string + - outCollection + description: | + The output collection. + - name: 'on' + type: + - string + - array # of string + 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. + - name: let + type: + - object + optional: true + description: | + Specifies variables for use in the whenMatched pipeline. + - name: whenMatched + type: + - whenMatched + - pipeline + optional: true + description: | + The behavior of $merge if a result document and an existing document in the collection have the same value for the specified on field(s). + - name: whenNotMatched + type: + - whenNotMatched + optional: true + description: | + 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' - pipeline: - - - $group: - _id: - fiscal_year: '$fiscal_year' - dept: '$dept' - salaries: - $sum: '$salary' - - - $merge: - into: - 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' - pipeline: - - - $match: - fiscal_year: - $gte: 2019 - - - $group: - _id: - fiscal_year: '$fiscal_year' - dept: '$dept' - salaries: - $sum: '$salary' - - - $merge: - into: - 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' - pipeline: - - - $match: - fiscal_year: 2019 - - - $group: - _id: - fiscal_year: '$fiscal_year' - dept: '$dept' - employees: - $push: '$employee' - - - $project: - _id: 0 - dept: '$_id.dept' - fiscal_year: '$_id.fiscal_year' - employees: 1 - - - $merge: - into: - 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' - pipeline: - - - $group: - _id: '$quarter' - purchased: - $sum: '$qty' - - - $merge: - 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' - pipeline: - - - $match: - date: - $gte: !bson_utcdatetime '2019-05-07' - $lt: !bson_utcdatetime '2019-05-08' - - - $project: - _id: - $dateToString: - format: '%Y-%m' - date: '$date' - thumbsup: 1 - thumbsdown: 1 - - - $merge: - into: 'monthlytotals' - on: '_id' - whenMatched: - - - $addFields: - thumbsup: - $add: - - '$thumbsup' - - '$$new.thumbsup' - thumbsdown: - $add: - - '$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' - pipeline: - - - $merge: - into: 'cakeSales' - let: - year: '2020' - whenMatched: - - - $addFields: - salesYear: '$$year' + - 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 + salaries: + $sum: $salary + - $merge: + into: + 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 + pipeline: + - $match: + fiscal_year: + $gte: 2019 + - $group: + _id: + fiscal_year: $fiscal_year + dept: $dept + salaries: + $sum: $salary + - $merge: + into: + 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 + pipeline: + - $match: + fiscal_year: 2019 + - $group: + _id: + fiscal_year: $fiscal_year + dept: $dept + employees: + $push: $employee + - $project: + _id: 0 + dept: $_id.dept + fiscal_year: $_id.fiscal_year + employees: 1 + - $merge: + into: + 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 + pipeline: + - $group: + _id: $quarter + purchased: + $sum: $qty + - $merge: + 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 + pipeline: + - $match: + date: + $gte: !bson_utcdatetime '2019-05-07' + $lt: !bson_utcdatetime '2019-05-08' + - $project: + _id: + $dateToString: + format: '%Y-%m' + date: $date + thumbsup: 1 + thumbsdown: 1 + - $merge: + into: monthlytotals + on: _id + whenMatched: + - $addFields: + thumbsup: + $add: + - $thumbsup + - $$new.thumbsup + thumbsdown: + $add: + - $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 + pipeline: + - $merge: + into: cakeSales + let: + year: '2020' + whenMatched: + - $addFields: + salesYear: $$year diff --git a/generator/config/stage/out.yaml b/generator/config/stage/out.yaml index 0c3597fdf..3dfc4e6ea 100644 --- a/generator/config/stage/out.yaml +++ b/generator/config/stage/out.yaml @@ -1,40 +1,34 @@ # $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 - type: - - string - - outCollection - description: | - Target database name to write documents from $out to. + - name: coll + type: + - string + - outCollection + description: | + 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' - pipeline: - - - $group: - _id: '$author' - books: - $push: '$title' - - - $out: 'authors' - - - 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' - books: - $push: '$title' - - - $out: - db: 'reporting' - coll: 'authors' + - name: Output to Same Database + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/#output-to-same-database + pipeline: + - $group: + _id: $author + books: + $push: $title + - $out: authors + - 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 + books: + $push: $title + - $out: + db: reporting + coll: authors diff --git a/generator/config/stage/planCacheStats.yaml b/generator/config/stage/planCacheStats.yaml index 995caa74e..e6c07c7de 100644 --- a/generator/config/stage/planCacheStats.yaml +++ b/generator/config/stage/planCacheStats.yaml @@ -1,24 +1,19 @@ # $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 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' - 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' - pipeline: - - - $planCacheStats: {} - - - $match: - planCacheKey: 'B1435201' + - 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 + pipeline: + - $planCacheStats: {} + - $match: + planCacheKey: B1435201 diff --git a/generator/config/stage/project.yaml b/generator/config/stage/project.yaml index bde7c420d..fb8cad138 100644 --- a/generator/config/stage/project.yaml +++ b/generator/config/stage/project.yaml @@ -1,124 +1,105 @@ # $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 description: | Reshapes each document in the stream, such as by adding new fields or removing existing fields. For each input document, outputs one document. arguments: - - - name: specification - type: - - expression - variadic: object # XXX: This should somehow allow explicit typings for { fieldName: 1|0 } + - name: specification + type: + - expression + variadic: object # XXX: This should somehow allow explicit typings for { fieldName: 1|0 } 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' - pipeline: - - - $project: + - 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 + pipeline: + - $project: + _id: 0 + 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 + 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 + pipeline: + - $project: + author.first: 0 + lastModified: 0 + - $project: + author: + first: 0 + lastModified: 0 + - name: Conditionally Exclude Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#conditionally-exclude-fields + pipeline: + - $project: + title: 1 + author.first: 1 + author.last: 1 + author.middle: + $cond: + if: + $eq: + - '' + - $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 + pipeline: + - $project: + stop.title: 1 + - $project: + stop: 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' - pipeline: - - - $project: - _id: 0 - 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' - 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' - pipeline: - - - $project: - author.first: 0 - lastModified: 0 - - - $project: - author: - first: 0 - lastModified: 0 - - - name: 'Conditionally Exclude Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#conditionally-exclude-fields' - pipeline: - - - $project: - title: 1 - author.first: 1 - author.last: 1 - author.middle: - $cond: - if: - $eq: - - '' - - '$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' - pipeline: - - - $project: - stop.title: 1 - - - $project: - stop: - title: 1 - - - name: 'Include Computed Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#include-computed-fields' - pipeline: - - - $project: - title: 1 - isbn: - prefix: - $substr: - - '$isbn' - - 0 - - 3 - group: - $substr: - - '$isbn' - - 3 - - 2 - publisher: - $substr: - - '$isbn' - - 5 - - 4 - title: - $substr: - - '$isbn' - - 9 - - 3 - checkDigit: - $substr: - - '$isbn' - - 12 - - 1 - 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' - pipeline: - - - $project: - myArray: - - '$x' - - '$y' + - name: Include Computed Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#include-computed-fields + pipeline: + - $project: + title: 1 + isbn: + prefix: + $substr: + - $isbn + - 0 + - 3 + group: + $substr: + - $isbn + - 3 + - 2 + publisher: + $substr: + - $isbn + - 5 + - 4 + title: + $substr: + - $isbn + - 9 + - 3 + checkDigit: + $substr: + - $isbn + - 12 + - 1 + 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 + pipeline: + - $project: + myArray: + - $x + - $y diff --git a/generator/config/stage/redact.yaml b/generator/config/stage/redact.yaml index 07698119c..56c81b919 100644 --- a/generator/config/stage/redact.yaml +++ b/generator/config/stage/redact.yaml @@ -1,52 +1,43 @@ # $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 description: | Reshapes each document in the stream by restricting the content for each document based on information stored in the documents themselves. Incorporates the functionality of $project and $match. Can be used to implement field level redaction. For each input document, outputs either one or zero documents. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - 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' - pipeline: - - - $match: - year: 2014 - - - $redact: - $cond: - if: - $gt: - - - $size: - $setIntersection: - - '$tags' - - - - 'STLW' - - 'G' - - 0 - 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' - pipeline: - - - $match: - status: 'A' - - - $redact: - $cond: - if: - $eq: - - '$level' - - 5 - then: '$$PRUNE' - else: '$$DESCEND' + - 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: + year: 2014 + - $redact: + $cond: + if: + $gt: + - $size: + $setIntersection: + - $tags + - - STLW + - G + - 0 + 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 + pipeline: + - $match: + status: A + - $redact: + $cond: + if: + $eq: + - $level + - 5 + then: $$PRUNE + else: $$DESCEND diff --git a/generator/config/stage/replaceRoot.yaml b/generator/config/stage/replaceRoot.yaml index 4de474e00..f483b58f7 100644 --- a/generator/config/stage/replaceRoot.yaml +++ b/generator/config/stage/replaceRoot.yaml @@ -1,71 +1,58 @@ # $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 description: | Replaces a document with the specified embedded document. The operation replaces all existing fields in the input document, including the _id field. Specify a document embedded in the input document to promote the embedded document to the top level. arguments: - - - name: newRoot - type: - - resolvesToObject + - name: newRoot + type: + - 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' - pipeline: - - - $replaceRoot: - newRoot: - $mergeObjects: - - - dogs: 0 - cats: 0 - birds: 0 - fish: 0 - - '$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' - pipeline: - - + - 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: + newRoot: + $mergeObjects: + - dogs: 0 + cats: 0 + birds: 0 + fish: 0 + - $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 + pipeline: # The builder uses the verbose form of the $unwind operator # $unwind: '$grades' - $unwind: - path: '$grades' - - - $match: - grades.grade: - $gte: 90 - - - $replaceRoot: - 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' - pipeline: - - - $replaceRoot: - newRoot: - full_name: - $concat: - - '$first_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' - pipeline: - - - $replaceRoot: - newRoot: - $mergeObjects: - - - _id: '' - name: '' - email: '' - cell: '' - home: '' - - '$$ROOT' + - $unwind: + path: $grades + - $match: + grades.grade: + $gte: 90 + - $replaceRoot: + 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 + pipeline: + - $replaceRoot: + newRoot: + full_name: + $concat: + - $first_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 + pipeline: + - $replaceRoot: + newRoot: + $mergeObjects: + - _id: '' + name: '' + email: '' + cell: '' + home: '' + - $$ROOT diff --git a/generator/config/stage/replaceWith.yaml b/generator/config/stage/replaceWith.yaml index 10c5fa3a2..62ba33c13 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 @@ -8,67 +8,53 @@ description: | Replaces a document with the specified embedded document. The operation replaces all existing fields in the input document, including the _id field. Specify a document embedded in the input document to promote the embedded document to the top level. Alias for $replaceRoot. arguments: - - - name: expression - type: - - resolvesToObject + - name: expression + type: + - resolvesToObject tests: - - - name: 'an Embedded Document Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/#-replacewith-an-embedded-document-field' - pipeline: - - - $replaceWith: - $mergeObjects: - - - dogs: 0 - cats: 0 - birds: 0 - fish: 0 - - '$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' - pipeline: - - + - name: an Embedded Document Field + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/#-replacewith-an-embedded-document-field + pipeline: + - $replaceWith: + $mergeObjects: + - dogs: 0 + cats: 0 + birds: 0 + fish: 0 + - $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 + pipeline: # The builder uses the verbose form of the $unwind operator # $unwind: '$grades' - $unwind: - path: '$grades' - - - $match: - grades.grade: - $gte: 90 - - - $replaceWith: '$grades' - - - 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' - - - $replaceWith: - _id: '$_id' - item: '$item' - amount: - $multiply: - - '$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' - pipeline: - - - $replaceWith: - $mergeObjects: - - - _id: '' - name: '' - email: '' - cell: '' - home: '' - - '$$ROOT' + - $unwind: + path: $grades + - $match: + grades.grade: + $gte: 90 + - $replaceWith: $grades + - 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 + - $replaceWith: + _id: $_id + item: $item + amount: + $multiply: + - $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 + pipeline: + - $replaceWith: + $mergeObjects: + - _id: '' + name: '' + email: '' + cell: '' + home: '' + - $$ROOT diff --git a/generator/config/stage/sample.yaml b/generator/config/stage/sample.yaml index 757382aaf..45efca026 100644 --- a/generator/config/stage/sample.yaml +++ b/generator/config/stage/sample.yaml @@ -1,23 +1,20 @@ # $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 description: | Randomly selects the specified number of documents from its input. arguments: - - - name: size - type: - - int - description: | - The number of documents to randomly select. + - name: size + type: + - int + description: | + The number of documents to randomly select. tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/#example' - pipeline: - - - $sample: - size: 3 + - name: Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/#example + pipeline: + - $sample: + size: 3 diff --git a/generator/config/stage/search.yaml b/generator/config/stage/search.yaml index 44756ce23..f38ec4437 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 @@ -8,258 +8,210 @@ description: | Performs a full-text search of the field or fields in an Atlas collection. NOTE: $search is only available for MongoDB Atlas clusters, and is not available for self-managed deployments. arguments: - - - name: operator - mergeObject: true - type: - - searchOperator - description: | - Operator to search with. You can provide a specific operator or use - the compound operator to run a compound query with multiple operators. - - - name: index - optional: true - type: - - string - description: | - Name of the Atlas Search index to use. If omitted, defaults to "default". - - - name: highlight - optional: true - type: + - name: operator + mergeObject: true + type: + - searchOperator + description: | + Operator to search with. You can provide a specific operator or use + the compound operator to run a compound query with multiple operators. + - name: index + optional: true + type: + - string + description: | + Name of the Atlas Search index to use. If omitted, defaults to "default". + - 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. - - - name: concurrent - optional: true - type: - - bool - description: | - Parallelize search across segments on dedicated search nodes. - If you don't have separate search nodes on your cluster, - Atlas Search ignores this flag. If omitted, defaults to false. - - - name: count - optional: true - type: - - object - description: | - Document that specifies the count options for retrieving a count of the results. - - - name: searchAfter - optional: true - type: - - string - description: | - Reference point for retrieving results. searchAfter returns documents starting immediately following the specified reference point. - - - name: searchBefore - optional: true - type: - - string - description: | - Reference point for retrieving results. searchBefore returns documents starting immediately before the specified reference point. - - - name: scoreDetails - optional: true - type: - - bool - description: | - Flag that specifies whether to retrieve a detailed breakdown of the score for the documents in the results. If omitted, defaults to false. - - - name: sort - optional: true - type: - - object - description: | - Document that specifies the fields to sort the Atlas Search results by in ascending or descending order. - - - name: returnStoredSource - optional: true - type: - - bool - description: | - Flag that specifies whether to perform a full document lookup on the backend database or return only stored source fields directly from Atlas Search. - - - name: tracking - optional: true - type: - - object - description: | - Document that specifies the tracking option to retrieve analytics information on the search terms. + - object + description: | + Specifies the highlighting options for displaying search terms in their original context. + - name: concurrent + optional: true + type: + - bool + description: | + Parallelize search across segments on dedicated search nodes. + If you don't have separate search nodes on your cluster, + Atlas Search ignores this flag. If omitted, defaults to false. + - name: count + optional: true + type: + - object + description: | + Document that specifies the count options for retrieving a count of the results. + - name: searchAfter + optional: true + type: + - string + description: | + Reference point for retrieving results. searchAfter returns documents starting immediately following the specified reference point. + - name: searchBefore + optional: true + type: + - string + description: | + Reference point for retrieving results. searchBefore returns documents starting immediately before the specified reference point. + - name: scoreDetails + optional: true + type: + - bool + description: | + Flag that specifies whether to retrieve a detailed breakdown of the score for the documents in the results. If omitted, defaults to false. + - name: sort + optional: true + type: + - object + description: | + Document that specifies the fields to sort the Atlas Search results by in ascending or descending order. + - name: returnStoredSource + optional: true + type: + - bool + description: | + Flag that specifies whether to perform a full document lookup on the backend database or return only stored source fields directly from Atlas Search. + - name: tracking + optional: true + type: + - object + description: | + 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' - pipeline: - - - $search: - near: - path: 'released' - origin: !bson_utcdatetime '2011-09-01T00:00:00.000+00:00' - pivot: 7776000000 - - - $project: - _id: 0 - title: 1 - released: 1 - - - $limit: 5 - - - $facet: - docs: [] - 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' - pipeline: - - - $search: - range: - path: 'released' - gt: !bson_utcdatetime '2010-01-01T00:00:00.000Z' - lt: !bson_utcdatetime '2015-01-01T00:00:00.000Z' - sort: - released: -1 - - - $limit: 5 - - - $project: - _id: 0 - title: 1 + - 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' + pivot: 7776000000 + - $project: + _id: 0 + title: 1 + released: 1 + - $limit: 5 + - $facet: + docs: [] + 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 + pipeline: + - $search: + range: + path: released + gt: !bson_utcdatetime '2010-01-01T00:00:00.000Z' + lt: !bson_utcdatetime '2015-01-01T00:00:00.000Z' + sort: + released: -1 + - $limit: 5 + - $project: + _id: 0 + title: 1 + released: 1 + - 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 + gt: 3 + sort: + awards.wins: -1 + - $limit: 5 + - $project: + _id: 0 + title: 1 + awards.wins: 1 + - name: Sort by score + link: https://www.mongodb.com/docs/atlas/atlas-search/sort/#sort-by-score + pipeline: + - $search: + text: + path: title + query: story + sort: + score: + $meta: searchScore + order: 1 + - $limit: 5 + - $project: + _id: 0 + title: 1 + score: + $meta: searchScore + - 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 + sort: + score: + $meta: searchScore released: 1 - - - 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' - gt: 3 - sort: - awards.wins: -1 - - - $limit: 5 - - - $project: - _id: 0 - title: 1 - awards.wins: 1 - - - name: 'Sort by score' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/sort/#sort-by-score' - pipeline: - - - $search: - text: - path: 'title' - query: 'story' - sort: - score: - $meta: 'searchScore' - order: 1 - - - $limit: 5 - - - $project: - _id: 0 - title: 1 + 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 + pipeline: + - $search: + text: + path: title + query: war + sort: score: - $meta: 'searchScore' - - - 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' - sort: - score: - $meta: 'searchScore' - released: 1 - 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' - pipeline: - - - $search: - text: - path: 'title' - query: 'war' - sort: - score: - $meta: 'searchScore' - released: 1 - searchBefore: 'CJ6kARoGELqvp4MIGgkpACDA3U8BAAA=' - - - 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' - pivot: 7776000000 - count: - type: 'total' - - - $project: - meta: '$$SEARCH_META' - title: 1 + $meta: searchScore released: 1 - - - $limit: 2 - - - name: 'Track Search terms' - link: 'https://www.mongodb.com/docs/atlas/atlas-search/tracking/#examples' - pipeline: - - - $search: - text: - query: 'summer' - path: 'title' - tracking: - searchTerms: 'summer' - - - $limit: 5 - - - $project: - _id: 0 - title: 1 - - - 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' - returnStoredSource: true - - - $match: - $or: - - - imdb.rating: - $gt: 8.2 - - - imdb.votes: - $gte: 4500 - - - $lookup: - from: 'movies' - localField: '_id' - foreignField: '_id' - as: 'document' + searchBefore: CJ6kARoGELqvp4MIGgkpACDA3U8BAAA= + - 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' + pivot: 7776000000 + count: + type: total + - $project: + meta: $$SEARCH_META + title: 1 + released: 1 + - $limit: 2 + - name: Track Search terms + link: https://www.mongodb.com/docs/atlas/atlas-search/tracking/#examples + pipeline: + - $search: + text: + query: summer + path: title + tracking: + searchTerms: summer + - $limit: 5 + - $project: + _id: 0 + title: 1 + - 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 + returnStoredSource: true + - $match: + $or: + - imdb.rating: + $gt: 8.2 + - imdb.votes: + $gte: 4500 + - $lookup: + from: movies + localField: _id + foreignField: _id + as: document diff --git a/generator/config/stage/searchMeta.yaml b/generator/config/stage/searchMeta.yaml index a7d92c272..31b53f427 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 @@ -8,125 +8,108 @@ description: | Returns different types of metadata result documents for the Atlas Search query against an Atlas collection. NOTE: $searchMeta is only available for MongoDB Atlas clusters running MongoDB v4.4.9 or higher, and is not available for self-managed deployments. arguments: - - - name: operator - mergeObject: true - type: - - searchOperator - description: | - Operator to search with. You can provide a specific operator or use - the compound operator to run a compound query with multiple operators. - - - name: index - optional: true - type: - - string - description: | - Name of the Atlas Search index to use. If omitted, defaults to default. - - - - name: count - optional: true - type: - - object - description: | - Document that specifies the count options for retrieving a count of the results. + - name: operator + mergeObject: true + type: + - searchOperator + description: | + Operator to search with. You can provide a specific operator or use + the compound operator to run a compound query with multiple operators. + - name: index + optional: true + type: + - string + description: | + Name of the Atlas Search index to use. If omitted, defaults to default. + - name: count + optional: true + type: + - object + description: | + 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' - pipeline: - - - $searchMeta: - range: - path: 'year' - gte: 1998 - lt: 1999 - count: - type: 'total' - - - - 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' - - - - 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' - facets: - yearFacet: - 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' - - - - 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' - facets: - directorsFacet: - type: 'string' - path: 'directors' - numBuckets: 7 - yearFacet: - 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' - pipeline: - - - $searchMeta: - facet: - operator: - autocomplete: - path: 'title' - query: 'Gravity' - facets: - titleFacet: - type: 'string' - path: 'title' + - name: Example + link: https://www.mongodb.com/docs/atlas/atlas-search/query-syntax/#example + pipeline: + - $searchMeta: + range: + path: year + gte: 1998 + lt: 1999 + count: + type: total + - 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 + - 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' + facets: + yearFacet: + 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 + - 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' + facets: + directorsFacet: + type: string + path: directors + numBuckets: 7 + yearFacet: + 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 + pipeline: + - $searchMeta: + facet: + operator: + autocomplete: + path: title + query: Gravity + facets: + titleFacet: + type: string + path: title diff --git a/generator/config/stage/set.yaml b/generator/config/stage/set.yaml index a5861aa29..eca5a9446 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 @@ -8,66 +8,55 @@ description: | Adds new fields to documents. Outputs documents that contain all existing fields from the input documents and newly added fields. Alias for $addFields. arguments: - - - name: field - type: - - expression - variadic: object + - name: field + type: + - expression + variadic: object tests: - - - name: 'Using Two $set Stages' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#using-two--set-stages' - pipeline: - - - $set: - totalHomework: + - 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'] - totalQuiz: + $sum: + - $homework + totalQuiz: # $sum: '$quiz' - $sum: ['$quiz'] - - - $set: - totalScore: - $add: - - '$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' - pipeline: - - - $set: - specs.fuel_type: 'unleaded' - - - 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' - pipeline: - - - $match: - _id: 1 - - - $set: - homework: - $concatArrays: - - '$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' - pipeline: - - - $set: - quizAverage: + $sum: + - $quiz + - $set: + totalScore: + $add: + - $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 + pipeline: + - $set: + specs.fuel_type: unleaded + - 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 + pipeline: + - $match: + _id: 1 + - $set: + homework: + $concatArrays: + - $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 + 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..2230388d7 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 @@ -8,137 +8,137 @@ description: | Groups documents into windows and applies one or more operators to the documents in each window. New in MongoDB 5.0. arguments: - - - name: sortBy - type: - - sortBy - description: | - Specifies the field(s) to sort the documents by in the partition. Uses the same syntax as the $sort stage. Default is no sorting. - - - name: output - type: - - object - description: | - Specifies the field(s) to append to the documents in the output returned by the $setWindowFields stage. Each field is set to the result returned by the window operator. - A field can contain dots to specify embedded document fields and array fields. The semantics for the embedded document dotted notation in the $setWindowFields stage are the same as the $addFields and $set stages. - - - name: partitionBy - type: - - expression - description: | - Specifies an expression to group the documents. In the $setWindowFields stage, the group of documents is known as a partition. Default is one partition for the entire collection. - optional: true + - name: sortBy + type: + - sortBy + description: | + Specifies the field(s) to sort the documents by in the partition. Uses the same syntax as the $sort stage. Default is no sorting. + - name: output + type: + - object + description: | + Specifies the field(s) to append to the documents in the output returned by the $setWindowFields stage. Each field is set to the result returned by the window operator. + A field can contain dots to specify embedded document fields and array fields. The semantics for the embedded document dotted notation in the $setWindowFields stage are the same as the $addFields and $set stages. + - name: partitionBy + type: + - expression + description: | + Specifies an expression to group the documents. In the $setWindowFields stage, the group of documents is known as a partition. Default is one partition for the entire collection. + 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' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - cumulativeQuantityForState: - $sum: '$quantity' - window: - 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' - pipeline: - - - $setWindowFields: - partitionBy: + - 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 + sortBy: + orderDate: 1 + output: + cumulativeQuantityForState: + $sum: $quantity + window: + 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 + pipeline: + - $setWindowFields: + partitionBy: # $year: '$orderDate' - $year: - date: '$orderDate' - sortBy: - orderDate: 1 - output: - cumulativeQuantityForYear: - $sum: '$quantity' - window: - 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' - pipeline: - - - $setWindowFields: - partitionBy: + $year: + date: $orderDate + sortBy: + orderDate: 1 + output: + cumulativeQuantityForYear: + $sum: $quantity + window: + 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 + pipeline: + - $setWindowFields: + partitionBy: # $year: '$orderDate' - $year: - date: '$orderDate' - sortBy: - orderDate: 1 - output: - averageQuantity: - $avg: '$quantity' - window: - 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' - pipeline: - - - $setWindowFields: - partitionBy: + $year: + date: $orderDate + sortBy: + orderDate: 1 + output: + averageQuantity: + $avg: $quantity + window: + 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 + pipeline: + - $setWindowFields: + partitionBy: # $year: '$orderDate' - $year: - date: '$orderDate' - sortBy: - orderDate: 1 - output: - cumulativeQuantityForYear: - $sum: '$quantity' - window: - documents: ['unbounded', 'current'] - maximumQuantityForYear: - $max: '$quantity' - window: - documents: ['unbounded', 'unbounded'] - - - name: 'Range Window Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#range-window-example' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - price: 1 - output: - quantityFromSimilarOrders: - $sum: '$quantity' - window: - 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' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - recentOrders: - $push: '$orderDate' - window: - 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' - pipeline: - - - $setWindowFields: - partitionBy: '$state' - sortBy: - orderDate: 1 - output: - recentOrders: - $push: '$orderDate' - window: - range: ['unbounded', -10] - unit: 'month' + $year: + date: $orderDate + sortBy: + orderDate: 1 + output: + cumulativeQuantityForYear: + $sum: $quantity + window: + documents: + - unbounded + - current + maximumQuantityForYear: + $max: $quantity + window: + documents: + - unbounded + - unbounded + - name: Range Window Example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#range-window-example + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + price: 1 + output: + quantityFromSimilarOrders: + $sum: $quantity + window: + 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 + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + recentOrders: + $push: $orderDate + window: + 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 + pipeline: + - $setWindowFields: + partitionBy: $state + sortBy: + orderDate: 1 + output: + recentOrders: + $push: $orderDate + window: + range: + - unbounded + - -10 + unit: month diff --git a/generator/config/stage/shardedDataDistribution.yaml b/generator/config/stage/shardedDataDistribution.yaml index 2f298ca0f..41cf0828d 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 @@ -8,9 +8,7 @@ description: | Provides data and size distribution information on sharded collections. New in MongoDB 6.0.3. tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/shardedDataDistribution/#examples' - pipeline: - - - $shardedDataDistribution: {} + - 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..cf1f9f43a 100644 --- a/generator/config/stage/skip.yaml +++ b/generator/config/stage/skip.yaml @@ -1,20 +1,17 @@ # $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 description: | Skips the first n documents where n is the specified skip number and passes the remaining documents unmodified to the pipeline. For each input document, outputs either zero documents (for the first n documents) or one document (if after the first n documents). arguments: - - - name: skip - type: - - int + - name: skip + type: + - int tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/#example' - pipeline: - - - $skip: 5 + - 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..54923075c 100644 --- a/generator/config/stage/sort.yaml +++ b/generator/config/stage/sort.yaml @@ -1,37 +1,31 @@ # $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 description: | Reorders the document stream by a specified sort key. Only the order changes; the documents remain unmodified. For each input document, outputs one document. arguments: - - - name: sort - type: - - expression - - sortSpec - variadic: object + - name: sort + type: + - expression + - sortSpec + variadic: object tests: - - - 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' - pipeline: - - - $match: - $text: - $search: 'operating' - - - $sort: - score: - $meta: 'textScore' - posts: -1 + - 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 + pipeline: + - $match: + $text: + $search: operating + - $sort: + score: + $meta: textScore + posts: -1 diff --git a/generator/config/stage/sortByCount.yaml b/generator/config/stage/sortByCount.yaml index a32d7aff4..378d6c7e3 100644 --- a/generator/config/stage/sortByCount.yaml +++ b/generator/config/stage/sortByCount.yaml @@ -1,25 +1,21 @@ # $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 description: | Groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group. arguments: - - - name: expression - type: - - expression + - name: expression + type: + - expression tests: - - - name: 'Example' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/#example' - pipeline: - - + - 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' - - - $sortByCount: '$tags' + - $unwind: + path: $tags + - $sortByCount: $tags diff --git a/generator/config/stage/unionWith.yaml b/generator/config/stage/unionWith.yaml index eafa44110..279f25c80 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 @@ -8,76 +8,59 @@ description: | Performs a union of two collections; i.e. combines pipeline results from two collections into a single result set. New in MongoDB 4.4. arguments: - - - name: coll - type: - - string - description: | - The collection or view whose pipeline results you wish to include in the result set. - - - name: pipeline - type: - - pipeline - optional: true - description: | - An aggregation pipeline to apply to the specified coll. - 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. + - name: coll + type: + - string + description: | + The collection or view whose pipeline results you wish to include in the result set. + - name: pipeline + type: + - pipeline + optional: true + description: | + An aggregation pipeline to apply to the specified coll. + 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' - pipeline: - - - $set: - _id: '2017' - - - $unionWith: - coll: 'sales_2018' - pipeline: - - - $set: - _id: '2018' - - - $unionWith: - coll: 'sales_2019' - pipeline: - - - $set: - _id: '2019' - - - $unionWith: - coll: 'sales_2020' - pipeline: - - - $set: - _id: '2020' - - - $sort: - _id: 1 - 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' - pipeline: - - + - 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 + pipeline: + - $set: + _id: '2018' + - $unionWith: + coll: sales_2019 + pipeline: + - $set: + _id: '2019' + - $unionWith: + coll: sales_2020 + pipeline: + - $set: + _id: '2020' + - $sort: + _id: 1 + 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 + pipeline: # Example uses the short form, the builder always generates the verbose form # $unionWith: 'sales_2018' - $unionWith: - coll: 'sales_2018' - - + - $unionWith: + coll: sales_2018 # $unionWith: 'sales_2019' - $unionWith: - coll: 'sales_2019' - - + - $unionWith: + coll: sales_2019 # $unionWith: 'sales_2020' - $unionWith: - coll: 'sales_2020' - - - $group: - _id: '$item' - total: - $sum: '$quantity' - - - $sort: - total: -1 + - $unionWith: + coll: sales_2020 + - $group: + _id: $item + total: + $sum: $quantity + - $sort: + total: -1 diff --git a/generator/config/stage/unset.yaml b/generator/config/stage/unset.yaml index cef9cdd6d..c9801552e 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 @@ -8,35 +8,29 @@ description: | Removes or excludes fields from documents. Alias for $project stage that removes or excludes fields. arguments: - - - name: field - type: - - fieldPath - variadic: array + - name: field + type: + - fieldPath + variadic: array tests: - - - name: 'Remove a Single Field' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/#remove-a-single-field' - pipeline: - - + - 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'] - - - name: 'Remove Top-Level Fields' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/#remove-top-level-fields' - pipeline: - - - $unset: - - 'isbn' - - 'copies' - - - 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' + - $unset: + - copies + - name: Remove Top-Level Fields + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/#remove-top-level-fields + pipeline: + - $unset: + - isbn + - copies + - 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 diff --git a/generator/config/stage/unwind.yaml b/generator/config/stage/unwind.yaml index a1f93edbc..3176045f3 100644 --- a/generator/config/stage/unwind.yaml +++ b/generator/config/stage/unwind.yaml @@ -1,95 +1,78 @@ # $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 description: | Deconstructs an array field from the input documents to output a document for each element. Each output document replaces the array with an element value. For each input document, outputs n documents where n is the number of array elements and can be zero for an empty array. arguments: - - - name: path - type: - - arrayFieldPath - description: | - Field path to an array field. - - - name: includeArrayIndex - type: - - string - optional: true - description: | - The name of a new field to hold the array index of the element. The name cannot start with a dollar sign $. - - - name: preserveNullAndEmptyArrays - type: - - bool - optional: true - description: | - If true, if the path is null, missing, or an empty array, $unwind outputs the document. - If false, if path is null, missing, or an empty array, $unwind does not output a document. - The default value is false. + - name: path + type: + - arrayFieldPath + description: | + Field path to an array field. + - name: includeArrayIndex + type: + - string + optional: true + description: | + The name of a new field to hold the array index of the element. The name cannot start with a dollar sign $. + - name: preserveNullAndEmptyArrays + type: + - bool + optional: true + description: | + If true, if the path is null, missing, or an empty array, $unwind outputs the document. + If false, if path is null, missing, or an empty array, $unwind does not output a document. + The default value is false. tests: - - - name: 'Unwind Array' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#unwind-array' - pipeline: - - + - 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' - - - name: 'preserveNullAndEmptyArrays' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#preservenullandemptyarrays' - pipeline: - - - $unwind: - path: '$sizes' - preserveNullAndEmptyArrays: true - - - name: 'includeArrayIndex' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#includearrayindex' - pipeline: - - - $unwind: - path: '$sizes' - includeArrayIndex: 'arrayIndex' - - - name: 'Group by Unwound Values' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#group-by-unwound-values' - pipeline: - - - $unwind: - path: '$sizes' - preserveNullAndEmptyArrays: true - - - $group: - _id: '$sizes' - averagePrice: - $avg: '$price' - - - $sort: - averagePrice: -1 - - - name: 'Unwind Embedded Arrays' - link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#unwind-embedded-arrays' - pipeline: - - + - $unwind: + path: $sizes + - name: preserveNullAndEmptyArrays + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#preservenullandemptyarrays + pipeline: + - $unwind: + path: $sizes + preserveNullAndEmptyArrays: true + - name: includeArrayIndex + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#includearrayindex + pipeline: + - $unwind: + path: $sizes + includeArrayIndex: arrayIndex + - name: Group by Unwound Values + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#group-by-unwound-values + pipeline: + - $unwind: + path: $sizes + preserveNullAndEmptyArrays: true + - $group: + _id: $sizes + averagePrice: + $avg: $price + - $sort: + averagePrice: -1 + - 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' - - + - $unwind: + path: $items # Example uses the short form, the builder always generates the verbose form # $unwind: '$items.tags' - $unwind: - path: '$items.tags' - - - $group: - _id: '$items.tags' - totalSalesAmount: - $sum: - $multiply: - - '$items.price' - - '$items.quantity' + - $unwind: + path: $items.tags + - $group: + _id: $items.tags + totalSalesAmount: + $sum: + $multiply: + - $items.price + - $items.quantity diff --git a/generator/config/stage/vectorSearch.yaml b/generator/config/stage/vectorSearch.yaml index bcd3c008a..114b27a2f 100644 --- a/generator/config/stage/vectorSearch.yaml +++ b/generator/config/stage/vectorSearch.yaml @@ -1,119 +1,108 @@ # $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 description: | The $vectorSearch stage performs an ANN or ENN search on a vector in the specified field. arguments: - - - name: index - type: - - string - description: | - Name of the Atlas Vector Search index to use. - - - name: limit - type: - - int - description: | - Number of documents to return in the results. This value can't exceed the value of numCandidates if you specify numCandidates. - - - name: path - type: - - string - description: | - Indexed vector type field to search. - - - name: queryVector - type: - - array # of numbers - description: | - Array of numbers that represent the query vector. The number type must match the indexed field value type. - - - name: exact - optional: true - type: - - bool - description: | - This is required if numCandidates is omitted. false to run ANN search. true to run ENN search. - - - name: filter - optional: true - type: - - query - description: | - Any match query that compares an indexed field with a boolean, date, objectId, number (not decimals), string, or UUID to use as a pre-filter. - - - name: numCandidates - optional: true - type: - - int - 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). - + - name: index + type: + - string + description: | + Name of the Atlas Vector Search index to use. + - name: limit + type: + - int + description: | + Number of documents to return in the results. This value can't exceed the value of numCandidates if you specify numCandidates. + - name: path + type: + - string + description: | + Indexed vector type field to search. + - name: queryVector + type: + - array # of numbers + description: | + Array of numbers that represent the query vector. The number type must match the indexed field value type. + - name: exact + optional: true + type: + - bool + description: | + This is required if numCandidates is omitted. false to run ANN search. true to run ENN search. + - name: filter + optional: true + type: + - query + description: | + Any match query that compares an indexed field with a boolean, date, objectId, number (not decimals), string, or UUID to use as a pre-filter. + - name: numCandidates + optional: true + type: + - int + 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' - pipeline: - - - $vectorSearch: - index: 'vector_index' - path: 'plot_embedding' - queryVector: [-0.0016261312, -0.028070757, -0.011342932] # skip other numbers, not relevant to the test - numCandidates: 150 - limit: 10 - - - $project: - _id: 0 - plot: 1 - title: 1 - score: - $meta: 'vectorSearchScore' - - - - 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' - filter: - $and: - - - year: - $lt: 1975 - queryVector: [0.02421053, -0.022372592, -0.006231137] # skip other numbers, not relevant to the test - numCandidates: 150 - limit: 10 - - - $project: - _id: 0 - title: 1 - plot: 1 - year: 1 - score: - $meta: 'vectorSearchScore' - - - - 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 - exact: true - limit: 10 - - - $project: - _id: 0 - plot: 1 - title: 1 - score: - $meta: 'vectorSearchScore' + - 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: # skip other numbers, not relevant to the test + - -0.0016261312 + - -0.028070757 + - -0.011342932 + numCandidates: 150 + limit: 10 + - $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: vectorSearchScore + - 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 + filter: + $and: + - year: + $lt: 1975 + queryVector: # skip other numbers, not relevant to the test + - 0.02421053 + - -0.022372592 + - -0.006231137 + numCandidates: 150 + limit: 10 + - $project: + _id: 0 + title: 1 + plot: 1 + year: 1 + score: + $meta: vectorSearchScore + - 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: # skip other numbers, not relevant to the test + - -0.006954097 + - -0.009932499 + - -0.001311474 + exact: true + limit: 10 + - $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: vectorSearchScore From 7cb22740c20399fd68d3983af7f126f6218571c8 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 22 May 2025 13:10:38 +0200 Subject: [PATCH 05/16] Reformat after running the js generator --- .../config/accumulator/covariancePop.yaml | 2 - .../config/accumulator/covarianceSamp.yaml | 2 - generator/config/accumulator/percentile.yaml | 2 +- generator/config/accumulator/push.yaml | 4 - generator/config/accumulator/sum.yaml | 4 - .../config/expression/arrayToObject.yaml | 2 - generator/config/expression/avg.yaml | 3 - generator/config/expression/bitAnd.yaml | 2 +- generator/config/expression/bitOr.yaml | 2 +- generator/config/expression/case.yaml | 3 +- generator/config/expression/dateAdd.yaml | 2 - .../config/expression/dateFromString.yaml | 2 +- generator/config/expression/dateSubtract.yaml | 4 - generator/config/expression/dayOfMonth.yaml | 2 - generator/config/expression/dayOfWeek.yaml | 2 - generator/config/expression/dayOfYear.yaml | 2 - generator/config/expression/getField.yaml | 4 - generator/config/expression/gt.yaml | 2 +- generator/config/expression/hour.yaml | 2 - generator/config/expression/isArray.yaml | 1 - generator/config/expression/isoDayOfWeek.yaml | 2 - generator/config/expression/isoWeek.yaml | 2 - generator/config/expression/isoWeekYear.yaml | 2 - generator/config/expression/let.yaml | 2 +- generator/config/expression/literal.yaml | 4 +- generator/config/expression/map.yaml | 2 - generator/config/expression/max.yaml | 3 - generator/config/expression/median.yaml | 2 +- generator/config/expression/millisecond.yaml | 2 - generator/config/expression/min.yaml | 3 - generator/config/expression/minute.yaml | 2 - generator/config/expression/month.yaml | 2 - .../config/expression/objectToArray.yaml | 3 - generator/config/expression/percentile.yaml | 6 +- generator/config/expression/pow.yaml | 2 - generator/config/expression/rand.yaml | 2 - generator/config/expression/range.yaml | 2 +- generator/config/expression/reduce.yaml | 1 - generator/config/expression/regexFind.yaml | 7 +- generator/config/expression/regexFindAll.yaml | 9 +-- generator/config/expression/regexMatch.yaml | 7 +- generator/config/expression/second.yaml | 2 - generator/config/expression/setField.yaml | 4 - .../config/expression/setIntersection.yaml | 1 - generator/config/expression/size.yaml | 2 - generator/config/expression/split.yaml | 2 +- generator/config/expression/stdDevPop.yaml | 2 - generator/config/expression/sum.yaml | 3 - generator/config/expression/switch.yaml | 6 +- generator/config/expression/unsetField.yaml | 2 - generator/config/expression/week.yaml | 2 - generator/config/expression/year.yaml | 2 - generator/config/expression/zip.yaml | 4 +- generator/config/query/bitsAllClear.yaml | 4 +- generator/config/query/bitsAllSet.yaml | 4 +- generator/config/query/bitsAnyClear.yaml | 4 +- generator/config/query/bitsAnySet.yaml | 4 +- generator/config/query/eq.yaml | 4 +- generator/config/query/geoIntersects.yaml | 30 +++++--- generator/config/query/geoWithin.yaml | 30 +++++--- generator/config/query/in.yaml | 6 +- generator/config/query/mod.yaml | 2 +- generator/config/query/nin.yaml | 2 +- generator/config/query/not.yaml | 2 +- generator/config/query/regex.yaml | 2 +- generator/config/query/type.yaml | 16 ---- generator/config/search/autocomplete.yaml | 2 +- generator/config/search/compound.yaml | 8 +- generator/config/search/equals.yaml | 6 +- generator/config/search/facet.yaml | 6 +- generator/config/search/geoShape.yaml | 74 ++++++++++++------- generator/config/search/geoWithin.yaml | 12 ++- generator/config/search/in.yaml | 12 +-- generator/config/search/moreLikeThis.yaml | 10 +-- generator/config/search/near.yaml | 2 +- generator/config/search/phrase.yaml | 2 +- generator/config/search/queryString.yaml | 5 +- generator/config/search/range.yaml | 4 +- generator/config/search/text.yaml | 2 +- generator/config/stage/addFields.yaml | 5 +- generator/config/stage/bucket.yaml | 6 +- generator/config/stage/bucketAuto.yaml | 2 +- generator/config/stage/collStats.yaml | 4 +- generator/config/stage/densify.yaml | 4 +- generator/config/stage/documents.yaml | 8 +- generator/config/stage/facet.yaml | 4 - generator/config/stage/fill.yaml | 6 +- generator/config/stage/group.yaml | 5 +- generator/config/stage/lookup.yaml | 2 +- generator/config/stage/merge.yaml | 6 +- generator/config/stage/project.yaml | 2 +- generator/config/stage/replaceRoot.yaml | 2 - generator/config/stage/replaceWith.yaml | 2 - generator/config/stage/search.yaml | 6 +- generator/config/stage/searchMeta.yaml | 8 +- generator/config/stage/set.yaml | 4 - generator/config/stage/setWindowFields.yaml | 3 - generator/config/stage/sortByCount.yaml | 2 - generator/config/stage/unionWith.yaml | 4 - generator/config/stage/unset.yaml | 3 - generator/config/stage/unwind.yaml | 6 -- generator/config/stage/vectorSearch.yaml | 8 +- 102 files changed, 200 insertions(+), 305 deletions(-) diff --git a/generator/config/accumulator/covariancePop.yaml b/generator/config/accumulator/covariancePop.yaml index 66777413c..df8262335 100644 --- a/generator/config/accumulator/covariancePop.yaml +++ b/generator/config/accumulator/covariancePop.yaml @@ -25,8 +25,6 @@ tests: output: covariancePopForState: $covariancePop: - # Example uses the short form, the builder always generates the verbose form - # $year: '$orderDate' - $year: date: $orderDate - $quantity diff --git a/generator/config/accumulator/covarianceSamp.yaml b/generator/config/accumulator/covarianceSamp.yaml index 84da2ccba..afaf76671 100644 --- a/generator/config/accumulator/covarianceSamp.yaml +++ b/generator/config/accumulator/covarianceSamp.yaml @@ -25,8 +25,6 @@ tests: output: covarianceSampForState: $covarianceSamp: - # Example uses the short form, the builder always generates the verbose form - # $year: '$orderDate' - $year: date: $orderDate - $quantity diff --git a/generator/config/accumulator/percentile.yaml b/generator/config/accumulator/percentile.yaml index 0cca80c08..a043a468c 100644 --- a/generator/config/accumulator/percentile.yaml +++ b/generator/config/accumulator/percentile.yaml @@ -20,7 +20,7 @@ arguments: $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. diff --git a/generator/config/accumulator/push.yaml b/generator/config/accumulator/push.yaml index f18856f8e..c2e4f041b 100644 --- a/generator/config/accumulator/push.yaml +++ b/generator/config/accumulator/push.yaml @@ -22,13 +22,9 @@ tests: - $group: _id: day: - # Example uses the short form, the builder always generates the verbose form - # $dayOfYear: '$date' $dayOfYear: date: $date year: - # Example uses the short form, the builder always generates the verbose form - # $year: '$date' $year: date: $date itemsSold: diff --git a/generator/config/accumulator/sum.yaml b/generator/config/accumulator/sum.yaml index d0e339899..85b4873f0 100644 --- a/generator/config/accumulator/sum.yaml +++ b/generator/config/accumulator/sum.yaml @@ -19,13 +19,9 @@ tests: - $group: _id: day: - # Example uses the short form, the builder always generates the verbose form - # $dayOfYear: '$date' $dayOfYear: date: $date year: - # Example uses the short form, the builder always generates the verbose form - # $year: '$date' $year: date: $date totalAmount: diff --git a/generator/config/expression/arrayToObject.yaml b/generator/config/expression/arrayToObject.yaml index 95b2fa7df..596b8e32e 100644 --- a/generator/config/expression/arrayToObject.yaml +++ b/generator/config/expression/arrayToObject.yaml @@ -17,8 +17,6 @@ tests: - $project: item: 1 dimensions: - # Example uses the short form, the builder always generates the verbose form - # $arrayToObject: '$dimensions' $arrayToObject: - $dimensions - name: $objectToArray and $arrayToObject Example diff --git a/generator/config/expression/avg.yaml b/generator/config/expression/avg.yaml index 6f8292171..62ff078b3 100644 --- a/generator/config/expression/avg.yaml +++ b/generator/config/expression/avg.yaml @@ -18,12 +18,9 @@ tests: pipeline: - $project: quizAvg: - # Example uses the short form, the builder always generates the verbose form - # $avg: '$quizzes' $avg: - $quizzes labAvg: - # $avg: '$labs' $avg: - $labs examAvg: diff --git a/generator/config/expression/bitAnd.yaml b/generator/config/expression/bitAnd.yaml index 64efdc8c6..5b04a1d8e 100644 --- a/generator/config/expression/bitAnd.yaml +++ b/generator/config/expression/bitAnd.yaml @@ -30,4 +30,4 @@ tests: result: $bitAnd: - $a - - {$numberLong: '63'} + - $numberLong: '63' diff --git a/generator/config/expression/bitOr.yaml b/generator/config/expression/bitOr.yaml index e6e70e74d..7c11de1b4 100644 --- a/generator/config/expression/bitOr.yaml +++ b/generator/config/expression/bitOr.yaml @@ -30,4 +30,4 @@ tests: result: $bitOr: - $a - - {$numberLong: '63'} + - $numberLong: '63' diff --git a/generator/config/expression/case.yaml b/generator/config/expression/case.yaml index c2df052cc..8c5cd9145 100644 --- a/generator/config/expression/case.yaml +++ b/generator/config/expression/case.yaml @@ -16,5 +16,4 @@ arguments: - name: then type: - expression - description: |- - Can be any valid expression. + description: Can be any valid expression. diff --git a/generator/config/expression/dateAdd.yaml b/generator/config/expression/dateAdd.yaml index b4b494cb2..5a17fe87f 100644 --- a/generator/config/expression/dateAdd.yaml +++ b/generator/config/expression/dateAdd.yaml @@ -39,8 +39,6 @@ tests: startDate: $purchaseDate unit: day amount: 3 - # Example uses the short form, the builder always generates the verbose form - # $merge: 'shipping' - $merge: into: shipping - name: Filter on a Date Range diff --git a/generator/config/expression/dateFromString.yaml b/generator/config/expression/dateFromString.yaml index c7d44a6ad..1a88431c9 100644 --- a/generator/config/expression/dateFromString.yaml +++ b/generator/config/expression/dateFromString.yaml @@ -65,4 +65,4 @@ tests: $dateFromString: dateString: $date timezone: $timezone - onNull: !bson_utcdatetime 0 + onNull: !bson_utcdatetime '0' diff --git a/generator/config/expression/dateSubtract.yaml b/generator/config/expression/dateSubtract.yaml index 5d2a85238..5a97f45d6 100644 --- a/generator/config/expression/dateSubtract.yaml +++ b/generator/config/expression/dateSubtract.yaml @@ -36,8 +36,6 @@ tests: - $match: $expr: $eq: - # Example uses the short form, the builder always generates the verbose form - # $month: '$logout' - $month: date: $logout - 1 @@ -47,8 +45,6 @@ tests: startDate: $logout unit: hour amount: 3 - # Example uses the short form, the builder always generates the verbose form - # $merge: 'connectionTime' - $merge: into: connectionTime - name: Filter by Relative Dates diff --git a/generator/config/expression/dayOfMonth.yaml b/generator/config/expression/dayOfMonth.yaml index 6975e03a3..a6e22b980 100644 --- a/generator/config/expression/dayOfMonth.yaml +++ b/generator/config/expression/dayOfMonth.yaml @@ -26,7 +26,5 @@ tests: pipeline: - $project: day: - # Example uses the short form, the builder always generates the verbose form - # $dayOfMonth: '$date' $dayOfMonth: date: $date diff --git a/generator/config/expression/dayOfWeek.yaml b/generator/config/expression/dayOfWeek.yaml index db658f456..1f2e84134 100644 --- a/generator/config/expression/dayOfWeek.yaml +++ b/generator/config/expression/dayOfWeek.yaml @@ -26,7 +26,5 @@ tests: pipeline: - $project: dayOfWeek: - # Example uses the short form, the builder always generates the verbose form - # $dayOfWeek: '$date' $dayOfWeek: date: $date diff --git a/generator/config/expression/dayOfYear.yaml b/generator/config/expression/dayOfYear.yaml index a9ede4a8c..ed529158f 100644 --- a/generator/config/expression/dayOfYear.yaml +++ b/generator/config/expression/dayOfYear.yaml @@ -26,7 +26,5 @@ tests: pipeline: - $project: dayOfYear: - # Example uses the short form, the builder always generates the verbose form - # $dayOfYear: '$date' $dayOfYear: date: $date diff --git a/generator/config/expression/getField.yaml b/generator/config/expression/getField.yaml index 2b6866893..c515a6a2a 100644 --- a/generator/config/expression/getField.yaml +++ b/generator/config/expression/getField.yaml @@ -28,8 +28,6 @@ tests: - $match: $expr: $gt: - # Example uses the short form, the builder always generates the verbose form - # $getField: 'price.usd' - $getField: field: price.usd - 200 @@ -40,8 +38,6 @@ tests: $expr: $gt: - $getField: - # Example uses the short form, the builder always generates the verbose form - # $literal: '$price' field: $literal: $price - 200 diff --git a/generator/config/expression/gt.yaml b/generator/config/expression/gt.yaml index d1b5e2687..0f0fdcfc6 100644 --- a/generator/config/expression/gt.yaml +++ b/generator/config/expression/gt.yaml @@ -12,7 +12,7 @@ arguments: - expression - 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 diff --git a/generator/config/expression/hour.yaml b/generator/config/expression/hour.yaml index aaff160ed..b30a02576 100644 --- a/generator/config/expression/hour.yaml +++ b/generator/config/expression/hour.yaml @@ -26,7 +26,5 @@ tests: pipeline: - $project: hour: - # Example uses the short form, the builder always generates the verbose form - # $hour: '$date' $hour: date: $date diff --git a/generator/config/expression/isArray.yaml b/generator/config/expression/isArray.yaml index 1a0904d28..3fedc269a 100644 --- a/generator/config/expression/isArray.yaml +++ b/generator/config/expression/isArray.yaml @@ -19,7 +19,6 @@ tests: $cond: if: $and: - # Example uses the short form, the builder always generates the verbose form - $isArray: - $instock - $isArray: diff --git a/generator/config/expression/isoDayOfWeek.yaml b/generator/config/expression/isoDayOfWeek.yaml index 724a112ba..7d8374db2 100644 --- a/generator/config/expression/isoDayOfWeek.yaml +++ b/generator/config/expression/isoDayOfWeek.yaml @@ -28,7 +28,5 @@ tests: _id: 0 name: $name dayOfWeek: - # Example uses the short form, the builder always generates the verbose form - # $isoDayOfWeek: '$birthday' $isoDayOfWeek: date: $birthday diff --git a/generator/config/expression/isoWeek.yaml b/generator/config/expression/isoWeek.yaml index e5f9910fd..f36c5d2e6 100644 --- a/generator/config/expression/isoWeek.yaml +++ b/generator/config/expression/isoWeek.yaml @@ -28,7 +28,5 @@ tests: _id: 0 city: $city weekNumber: - # Example uses the short form, the builder always generates the verbose form - # $isoWeek: '$date' $isoWeek: date: $date diff --git a/generator/config/expression/isoWeekYear.yaml b/generator/config/expression/isoWeekYear.yaml index a63bab1f1..d390f7de2 100644 --- a/generator/config/expression/isoWeekYear.yaml +++ b/generator/config/expression/isoWeekYear.yaml @@ -26,7 +26,5 @@ tests: pipeline: - $project: yearNumber: - # Example uses the short form, the builder always generates the verbose form - # $isoWeekYear: '$date' $isoWeekYear: date: $date diff --git a/generator/config/expression/let.yaml b/generator/config/expression/let.yaml index 8c9305e6e..a6285f140 100644 --- a/generator/config/expression/let.yaml +++ b/generator/config/expression/let.yaml @@ -10,7 +10,7 @@ description: | 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. diff --git a/generator/config/expression/literal.yaml b/generator/config/expression/literal.yaml index 169986ff9..deadd72bf 100644 --- a/generator/config/expression/literal.yaml +++ b/generator/config/expression/literal.yaml @@ -10,5 +10,5 @@ arguments: - name: value type: - any - description: |- - If the value is an expression, $literal does not evaluate the expression but instead returns the unparsed expression. + description: If the value is an expression, $literal does not evaluate the expression + but instead returns the unparsed expression. diff --git a/generator/config/expression/map.yaml b/generator/config/expression/map.yaml index 113f1a353..152957ecf 100644 --- a/generator/config/expression/map.yaml +++ b/generator/config/expression/map.yaml @@ -46,8 +46,6 @@ tests: input: $distances as: decimalValue in: - # Example uses the short form, the builder always generates the verbose form - # $trunc: '$$decimalValue' $trunc: - $$decimalValue - name: Convert Celsius Temperatures to Fahrenheit diff --git a/generator/config/expression/max.yaml b/generator/config/expression/max.yaml index 9b90d486d..2240c43b6 100644 --- a/generator/config/expression/max.yaml +++ b/generator/config/expression/max.yaml @@ -18,12 +18,9 @@ tests: pipeline: - $project: quizMax: - # Example uses the short form, the builder always generates the verbose form - # $max: '$quizzes' $max: - $quizzes labMax: - # $max: '$labs' $max: - $labs examMax: diff --git a/generator/config/expression/median.yaml b/generator/config/expression/median.yaml index 8651af7ab..6ef1c6425 100644 --- a/generator/config/expression/median.yaml +++ b/generator/config/expression/median.yaml @@ -15,7 +15,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. - name: method diff --git a/generator/config/expression/millisecond.yaml b/generator/config/expression/millisecond.yaml index 6aface11f..a6200788f 100644 --- a/generator/config/expression/millisecond.yaml +++ b/generator/config/expression/millisecond.yaml @@ -26,7 +26,5 @@ tests: pipeline: - $project: milliseconds: - # Example uses the short form, the builder always generates the verbose form - # $millisecond: '$date' $millisecond: date: $date diff --git a/generator/config/expression/min.yaml b/generator/config/expression/min.yaml index cce7838f3..80fdef1ac 100644 --- a/generator/config/expression/min.yaml +++ b/generator/config/expression/min.yaml @@ -18,12 +18,9 @@ tests: pipeline: - $project: quizMin: - # Example uses the short form, the builder always generates the verbose form - # $min: '$quizzes' $min: - $quizzes labMin: - # $min: '$labs' $min: - $labs examMin: diff --git a/generator/config/expression/minute.yaml b/generator/config/expression/minute.yaml index 8881b213f..06997a6a0 100644 --- a/generator/config/expression/minute.yaml +++ b/generator/config/expression/minute.yaml @@ -26,7 +26,5 @@ tests: pipeline: - $project: minutes: - # Example uses the short form, the builder always generates the verbose form - # $minute: '$date' $minute: date: $date diff --git a/generator/config/expression/month.yaml b/generator/config/expression/month.yaml index 9c36bd234..51321d3f6 100644 --- a/generator/config/expression/month.yaml +++ b/generator/config/expression/month.yaml @@ -26,7 +26,5 @@ tests: pipeline: - $project: month: - # Example uses the short form, the builder always generates the verbose form - # $month: '$date' $month: date: $date diff --git a/generator/config/expression/objectToArray.yaml b/generator/config/expression/objectToArray.yaml index a1793779a..503a80db6 100644 --- a/generator/config/expression/objectToArray.yaml +++ b/generator/config/expression/objectToArray.yaml @@ -13,7 +13,6 @@ 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 pipeline: @@ -27,8 +26,6 @@ tests: - $project: warehouses: $objectToArray: $instock - # Example uses the short form, the builder always generates the verbose form - # $unwind: '$warehouses' - $unwind: path: $warehouses - $group: diff --git a/generator/config/expression/percentile.yaml b/generator/config/expression/percentile.yaml index c98cd12ed..25b9ecbd9 100644 --- a/generator/config/expression/percentile.yaml +++ b/generator/config/expression/percentile.yaml @@ -2,7 +2,7 @@ name: $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. @@ -15,12 +15,12 @@ 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. diff --git a/generator/config/expression/pow.yaml b/generator/config/expression/pow.yaml index f66752681..7588d3eeb 100644 --- a/generator/config/expression/pow.yaml +++ b/generator/config/expression/pow.yaml @@ -20,8 +20,6 @@ tests: - $project: variance: $pow: - # Example uses the short form, the builder always generates the verbose form - # $stdDevPop: '$scores.score' - $stdDevPop: - $scores.score - 2 diff --git a/generator/config/expression/rand.yaml b/generator/config/expression/rand.yaml index d228e9fac..a119a1596 100644 --- a/generator/config/expression/rand.yaml +++ b/generator/config/expression/rand.yaml @@ -18,8 +18,6 @@ tests: - $set: amount: $floor: $amount - # Example uses the short form, the builder always generates the verbose form - # $merge: 'donors' - $merge: into: donors - name: Select Random Items From a Collection diff --git a/generator/config/expression/range.yaml b/generator/config/expression/range.yaml index ebbeed7d7..911cb9596 100644 --- a/generator/config/expression/range.yaml +++ b/generator/config/expression/range.yaml @@ -2,7 +2,7 @@ name: $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. diff --git a/generator/config/expression/reduce.yaml b/generator/config/expression/reduce.yaml index 8c5507df1..32211a5ea 100644 --- a/generator/config/expression/reduce.yaml +++ b/generator/config/expression/reduce.yaml @@ -62,7 +62,6 @@ tests: - 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: $gt: [] diff --git a/generator/config/expression/regexFind.yaml b/generator/config/expression/regexFind.yaml index c4ad11bea..346093494 100644 --- a/generator/config/expression/regexFind.yaml +++ b/generator/config/expression/regexFind.yaml @@ -31,13 +31,12 @@ tests: returnObject: $regexFind: input: $description - regex: !bson_regex 'line' + regex: !bson_regex line - 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 @@ -45,15 +44,13 @@ tests: - i - $addFields: returnObject: - # Specify i in the options field $regexFind: input: $description regex: line options: i - $addFields: returnObject: - # Mix Regex type with options field $regexFind: input: $description - regex: !bson_regex 'line' + regex: !bson_regex line options: i diff --git a/generator/config/expression/regexFindAll.yaml b/generator/config/expression/regexFindAll.yaml index 3b6166db8..7e60baac2 100644 --- a/generator/config/expression/regexFindAll.yaml +++ b/generator/config/expression/regexFindAll.yaml @@ -2,7 +2,7 @@ name: $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. @@ -31,13 +31,12 @@ tests: returnObject: $regexFindAll: input: $description - regex: !bson_regex 'line' + regex: !bson_regex line - 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 @@ -45,17 +44,15 @@ tests: - i - $addFields: returnObject: - # Specify i in the options field $regexFindAll: input: $description regex: line options: i - $addFields: returnObject: - # Mix Regex type with options field $regexFindAll: input: $description - regex: !bson_regex 'line' + regex: !bson_regex line 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 diff --git a/generator/config/expression/regexMatch.yaml b/generator/config/expression/regexMatch.yaml index eaa6b6489..9d4016fbd 100644 --- a/generator/config/expression/regexMatch.yaml +++ b/generator/config/expression/regexMatch.yaml @@ -31,13 +31,12 @@ tests: result: $regexMatch: input: $description - regex: !bson_regex 'line' + regex: !bson_regex line - 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 @@ -45,17 +44,15 @@ tests: - i - $addFields: result: - # Specify i in the options field $regexMatch: input: $description regex: line options: i - $addFields: result: - # Mix Regex type with options field $regexMatch: input: $description - regex: !bson_regex 'line' + regex: !bson_regex line 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 diff --git a/generator/config/expression/second.yaml b/generator/config/expression/second.yaml index ce3ec84bf..11622edca 100644 --- a/generator/config/expression/second.yaml +++ b/generator/config/expression/second.yaml @@ -26,7 +26,5 @@ tests: pipeline: - $project: seconds: - # Example uses the short form, the builder always generates the verbose form - # $second: '$date' $second: date: $date diff --git a/generator/config/expression/setField.yaml b/generator/config/expression/setField.yaml index e1661af6c..6f91c4504 100644 --- a/generator/config/expression/setField.yaml +++ b/generator/config/expression/setField.yaml @@ -33,8 +33,6 @@ tests: field: price.usd input: $$ROOT value: $price - # Example uses the short form, the builder always generates the verbose form - # $unset: 'price' - $unset: - price - name: Add Fields that Start with a Dollar Sign @@ -46,8 +44,6 @@ tests: $literal: $price input: $$ROOT value: $price - # Example uses the short form, the builder always generates the verbose form - # $unset: 'price' - $unset: - price - name: Update Fields that Contain Periods diff --git a/generator/config/expression/setIntersection.yaml b/generator/config/expression/setIntersection.yaml index 2ee76717c..5385b82ae 100644 --- a/generator/config/expression/setIntersection.yaml +++ b/generator/config/expression/setIntersection.yaml @@ -29,7 +29,6 @@ tests: - $match: $expr: $not: - # the example doesn't use an array inside $not, but the documentation say it is necessary - $eq: - $setIntersection: - $allowedRoles diff --git a/generator/config/expression/size.yaml b/generator/config/expression/size.yaml index acd2dd7fa..910715587 100644 --- a/generator/config/expression/size.yaml +++ b/generator/config/expression/size.yaml @@ -21,8 +21,6 @@ tests: numberOfColors: $cond: if: - # Example uses the short form, the builder always generates the verbose form - # $isArray: '$colors' $isArray: - $colors then: diff --git a/generator/config/expression/split.yaml b/generator/config/expression/split.yaml index 7f9621be4..ce08ffe3d 100644 --- a/generator/config/expression/split.yaml +++ b/generator/config/expression/split.yaml @@ -2,7 +2,7 @@ name: $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. diff --git a/generator/config/expression/stdDevPop.yaml b/generator/config/expression/stdDevPop.yaml index e525618d4..45ec5804f 100644 --- a/generator/config/expression/stdDevPop.yaml +++ b/generator/config/expression/stdDevPop.yaml @@ -19,7 +19,5 @@ tests: pipeline: - $project: stdDev: - # Example uses the short form, the builder always generates the verbose form - # $stdDevPop: '$scores.score' $stdDevPop: - $scores.score diff --git a/generator/config/expression/sum.yaml b/generator/config/expression/sum.yaml index 6261d5a1e..626905350 100644 --- a/generator/config/expression/sum.yaml +++ b/generator/config/expression/sum.yaml @@ -19,12 +19,9 @@ tests: pipeline: - $project: quizTotal: - # Example uses the short form, the builder always generates the verbose form - # $sum: '$quizzes' $sum: - $quizzes labTotal: - # $sum: '$labs' $sum: - $labs examTotal: diff --git a/generator/config/expression/switch.yaml b/generator/config/expression/switch.yaml index 9b4f9003a..33e39ee18 100644 --- a/generator/config/expression/switch.yaml +++ b/generator/config/expression/switch.yaml @@ -9,7 +9,7 @@ description: | 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. @@ -33,7 +33,6 @@ tests: branches: - case: $gte: - #$avg: '$scores' - $avg: - $scores - 90 @@ -41,19 +40,16 @@ tests: - case: $and: - $gte: - #$avg: '$scores' - $avg: - $scores - 80 - $lt: - #$avg: '$scores' - $avg: - $scores - 90 then: Doing pretty well. - case: $lt: - #$avg: '$scores' - $avg: - $scores - 80 diff --git a/generator/config/expression/unsetField.yaml b/generator/config/expression/unsetField.yaml index 3b5633f9c..4dc863852 100644 --- a/generator/config/expression/unsetField.yaml +++ b/generator/config/expression/unsetField.yaml @@ -45,7 +45,5 @@ tests: $unsetField: field: euro input: - # Example uses the short form, the builder always generates the verbose form - # $getField: 'price' $getField: field: price diff --git a/generator/config/expression/week.yaml b/generator/config/expression/week.yaml index ebfeb0dcb..09324d4cc 100644 --- a/generator/config/expression/week.yaml +++ b/generator/config/expression/week.yaml @@ -26,7 +26,5 @@ tests: pipeline: - $project: week: - # Example uses the short form, the builder always generates the verbose form - # $week: '$date' $week: date: $date diff --git a/generator/config/expression/year.yaml b/generator/config/expression/year.yaml index 6b3babbf2..c6d664ea8 100644 --- a/generator/config/expression/year.yaml +++ b/generator/config/expression/year.yaml @@ -26,7 +26,5 @@ tests: pipeline: - $project: year: - # Example uses the short form, the builder always generates the verbose form - # $year: '$date' $year: date: $date diff --git a/generator/config/expression/zip.yaml b/generator/config/expression/zip.yaml index f9e99e5ef..80f677bfe 100644 --- a/generator/config/expression/zip.yaml +++ b/generator/config/expression/zip.yaml @@ -2,14 +2,14 @@ name: $zip link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/ type: - - resolvesToArray # of array + - resolvesToArray encode: object description: | Merge two arrays together. 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. diff --git a/generator/config/query/bitsAllClear.yaml b/generator/config/query/bitsAllClear.yaml index 37061b97f..08151f6d3 100644 --- a/generator/config/query/bitsAllClear.yaml +++ b/generator/config/query/bitsAllClear.yaml @@ -11,7 +11,7 @@ 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 @@ -32,4 +32,4 @@ tests: pipeline: - $match: a: - $bitsAllClear: !bson_binary 'IA==' + $bitsAllClear: !bson_binary IA== diff --git a/generator/config/query/bitsAllSet.yaml b/generator/config/query/bitsAllSet.yaml index c02ffbfd9..8ed3d9fea 100644 --- a/generator/config/query/bitsAllSet.yaml +++ b/generator/config/query/bitsAllSet.yaml @@ -11,7 +11,7 @@ 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 @@ -32,4 +32,4 @@ tests: pipeline: - $match: a: - $bitsAllSet: !bson_binary 'MA==' + $bitsAllSet: !bson_binary MA== diff --git a/generator/config/query/bitsAnyClear.yaml b/generator/config/query/bitsAnyClear.yaml index d0c75345a..4f649b8e2 100644 --- a/generator/config/query/bitsAnyClear.yaml +++ b/generator/config/query/bitsAnyClear.yaml @@ -11,7 +11,7 @@ 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 @@ -32,4 +32,4 @@ tests: pipeline: - $match: a: - $bitsAnyClear: !bson_binary 'MA==' + $bitsAnyClear: !bson_binary MA== diff --git a/generator/config/query/bitsAnySet.yaml b/generator/config/query/bitsAnySet.yaml index 53f54c39f..10bef034d 100644 --- a/generator/config/query/bitsAnySet.yaml +++ b/generator/config/query/bitsAnySet.yaml @@ -11,7 +11,7 @@ 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 @@ -32,4 +32,4 @@ tests: pipeline: - $match: a: - $bitsAnySet: !bson_binary 'MA==' + $bitsAnySet: !bson_binary MA== diff --git a/generator/config/query/eq.yaml b/generator/config/query/eq.yaml index c5938e58c..fa6060e93 100644 --- a/generator/config/query/eq.yaml +++ b/generator/config/query/eq.yaml @@ -40,7 +40,7 @@ tests: company: $eq: MongoDB - $match: - company: !bson_regex '^MongoDB' + company: !bson_regex ^MongoDB - $match: company: - $eq: !bson_regex '^MongoDB' + $eq: !bson_regex ^MongoDB diff --git a/generator/config/query/geoIntersects.yaml b/generator/config/query/geoIntersects.yaml index 0b540be8d..075bc280d 100644 --- a/generator/config/query/geoIntersects.yaml +++ b/generator/config/query/geoIntersects.yaml @@ -21,10 +21,14 @@ tests: $geometry: 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 pipeline: @@ -34,12 +38,18 @@ tests: $geometry: 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 properties: diff --git a/generator/config/query/geoWithin.yaml b/generator/config/query/geoWithin.yaml index 0cb439962..d5216d1b0 100644 --- a/generator/config/query/geoWithin.yaml +++ b/generator/config/query/geoWithin.yaml @@ -21,10 +21,14 @@ tests: $geometry: 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 pipeline: @@ -34,12 +38,18 @@ tests: $geometry: 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 properties: diff --git a/generator/config/query/in.yaml b/generator/config/query/in.yaml index c5bd9b1d2..0922f839b 100644 --- a/generator/config/query/in.yaml +++ b/generator/config/query/in.yaml @@ -9,7 +9,7 @@ description: | 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 @@ -25,5 +25,5 @@ tests: - $match: tags: $in: - - !bson_regex '^be' - - !bson_regex '^st' + - !bson_regex ^be + - !bson_regex ^st diff --git a/generator/config/query/mod.yaml b/generator/config/query/mod.yaml index 692a18f15..e7451623a 100644 --- a/generator/config/query/mod.yaml +++ b/generator/config/query/mod.yaml @@ -28,7 +28,7 @@ tests: - $match: qty: $mod: - - 4.0 + - 4 - 0 - $match: qty: diff --git a/generator/config/query/nin.yaml b/generator/config/query/nin.yaml index 36eeeadbd..8de46630c 100644 --- a/generator/config/query/nin.yaml +++ b/generator/config/query/nin.yaml @@ -9,7 +9,7 @@ description: | 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 diff --git a/generator/config/query/not.yaml b/generator/config/query/not.yaml index 142c11795..4a843c4fc 100644 --- a/generator/config/query/not.yaml +++ b/generator/config/query/not.yaml @@ -23,4 +23,4 @@ tests: pipeline: - $match: price: - $not: !bson_regex '^p.*' + $not: !bson_regex ^p.* diff --git a/generator/config/query/regex.yaml b/generator/config/query/regex.yaml index 033901db0..9ab5ce6e9 100644 --- a/generator/config/query/regex.yaml +++ b/generator/config/query/regex.yaml @@ -16,7 +16,7 @@ tests: pipeline: - $match: sku: - $regex: !bson_regex '789$' + $regex: !bson_regex 789$ - 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: diff --git a/generator/config/query/type.yaml b/generator/config/query/type.yaml index 924cc39f1..208222646 100644 --- a/generator/config/query/type.yaml +++ b/generator/config/query/type.yaml @@ -18,32 +18,22 @@ tests: pipeline: - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 2 $type: - 2 - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'string' $type: - string - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 1 $type: - 1 - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'double' $type: - double - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'number' $type: - number - name: Querying by Multiple Data Type @@ -64,14 +54,10 @@ tests: pipeline: - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'minKey' $type: - minKey - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'maxKey' $type: - maxKey - name: Querying by Array Type @@ -79,7 +65,5 @@ tests: pipeline: - $match: zipCode: - # Example uses the short form, the builder always generates the verbose form - # $type: 'array' $type: - array diff --git a/generator/config/search/autocomplete.yaml b/generator/config/search/autocomplete.yaml index 508d3b1d2..8a544b768 100644 --- a/generator/config/search/autocomplete.yaml +++ b/generator/config/search/autocomplete.yaml @@ -19,7 +19,7 @@ arguments: - name: tokenOrder optional: true type: - - string # any|sequential + - string - name: fuzzy optional: true type: diff --git a/generator/config/search/compound.yaml b/generator/config/search/compound.yaml index 6426e5168..50fc502cc 100644 --- a/generator/config/search/compound.yaml +++ b/generator/config/search/compound.yaml @@ -13,22 +13,22 @@ 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 type: diff --git a/generator/config/search/equals.yaml b/generator/config/search/equals.yaml index f3fc4fa2b..d04115d18 100644 --- a/generator/config/search/equals.yaml +++ b/generator/config/search/equals.yaml @@ -42,14 +42,14 @@ tests: - $search: equals: path: teammates - value: !bson_objectId '5a9427648b0beebeb69589a1' + value: !bson_objectId 5a9427648b0beebeb69589a1 - 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' + value: !bson_utcdatetime '2022-05-04T05:01:08.000Z' - name: Number link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#number-example pipeline: @@ -70,7 +70,7 @@ tests: - $search: equals: path: uuid - value: !bson_uuid 'fac32260-b511-4c69-8485-a2be5b7dda9e' + value: !bson_uuid fac32260-b511-4c69-8485-a2be5b7dda9e - name: 'Null' link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#null-example pipeline: diff --git a/generator/config/search/facet.yaml b/generator/config/search/facet.yaml index 39f691919..a8aff34ba 100644 --- a/generator/config/search/facet.yaml +++ b/generator/config/search/facet.yaml @@ -2,7 +2,7 @@ name: 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 @@ -10,7 +10,7 @@ description: | arguments: - name: facets type: - - object # map of facetDefinition + - object - name: operator optional: true type: @@ -24,7 +24,7 @@ tests: operator: near: path: released - origin: !bson_utcdatetime '1999-07-01T00:00:00.000+00:00' + origin: !bson_utcdatetime '1999-07-01T00:00:00.000Z' pivot: 7776000000 facets: genresFacet: diff --git a/generator/config/search/geoShape.yaml b/generator/config/search/geoShape.yaml index 1e4f89ce8..d7b1080e7 100644 --- a/generator/config/search/geoShape.yaml +++ b/generator/config/search/geoShape.yaml @@ -13,7 +13,7 @@ arguments: - searchPath - name: relation type: - - string # contains | disjoint | intersects | within + - string - name: geometry type: - geometry @@ -31,10 +31,14 @@ tests: geometry: type: Polygon coordinates: - - - [-161.323242, 22.512557] - - [-152.446289, 22.065278] - - [-156.09375, 17.811456] - - [-161.323242, 22.512557] + - - - -161.323242 + - 22.512557 + - - -152.446289 + - 22.065278 + - - -156.09375 + - 17.811456 + - - -161.323242 + - 22.512557 path: address.location - $limit: 3 - $project: @@ -52,18 +56,30 @@ tests: geometry: 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.16365, 41.39416] - - [2.16963, 41.39726] - - [2.15395, 41.38005] - - [2.17935, 41.43038] - - [2.16365, 41.39416] + - - - - 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 - $limit: 3 - $project: @@ -81,14 +97,22 @@ tests: geometry: 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] + - - - -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 - $project: diff --git a/generator/config/search/geoWithin.yaml b/generator/config/search/geoWithin.yaml index eef050c3d..5a79865b2 100644 --- a/generator/config/search/geoWithin.yaml +++ b/generator/config/search/geoWithin.yaml @@ -77,10 +77,14 @@ tests: geometry: type: Polygon coordinates: - - - [-161.323242, 22.512557] - - [-152.446289, 22.065278] - - [-156.09375, 17.811456] - - [-161.323242, 22.512557] + - - - -161.323242 + - 22.512557 + - - -152.446289 + - 22.065278 + - - -156.09375 + - 17.811456 + - - -161.323242 + - 22.512557 path: address.location - $limit: 3 - $project: diff --git a/generator/config/search/in.yaml b/generator/config/search/in.yaml index 94182b2e1..37b9e18a7 100644 --- a/generator/config/search/in.yaml +++ b/generator/config/search/in.yaml @@ -13,7 +13,7 @@ arguments: - name: value type: - any - - array # of any + - array - name: score optional: true type: @@ -26,9 +26,9 @@ tests: in: 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' + - !bson_utcdatetime '1977-03-02T02:20:31.000Z' + - !bson_utcdatetime '1977-03-01T00:00:00.000Z' + - !bson_utcdatetime '1977-05-06T21:57:35.000Z' - $project: _id: 0 name: 1 @@ -62,8 +62,8 @@ tests: - in: path: _id value: - - !bson_objectId '5ca4bbcea2dd94ee58162a72' - - !bson_objectId '5ca4bbcea2dd94ee58162a91' + - !bson_objectId 5ca4bbcea2dd94ee58162a72 + - !bson_objectId 5ca4bbcea2dd94ee58162a91 - $limit: 5 - $project: _id: 1 diff --git a/generator/config/search/moreLikeThis.yaml b/generator/config/search/moreLikeThis.yaml index d5cb1d3fb..6fd005c3b 100644 --- a/generator/config/search/moreLikeThis.yaml +++ b/generator/config/search/moreLikeThis.yaml @@ -12,7 +12,7 @@ arguments: - name: like type: - object - - array # of object + - array - name: score optional: true type: @@ -40,7 +40,7 @@ tests: must: - moreLikeThis: like: - _id: !bson_objectId '573a1396f29313caabce4a9a' + _id: !bson_objectId 573a1396f29313caabce4a9a genres: - Crime - Drama @@ -48,7 +48,7 @@ tests: mustNot: - equals: path: _id - value: !bson_objectId '573a1396f29313caabce4a9a' + value: !bson_objectId 573a1396f29313caabce4a9a - $limit: 5 - $project: _id: 1 @@ -63,7 +63,7 @@ tests: should: - moreLikeThis: like: - _id: !bson_objectId '573a1396f29313caabce4a9a' + _id: !bson_objectId 573a1396f29313caabce4a9a genres: - Crime - Drama @@ -71,7 +71,7 @@ tests: mustNot: - equals: path: _id - value: !bson_objectId '573a1394f29313caabcde9ef' + value: !bson_objectId 573a1394f29313caabcde9ef - $limit: 10 - $project: title: 1 diff --git a/generator/config/search/near.yaml b/generator/config/search/near.yaml index 8c6a7e5de..f4f7c0867 100644 --- a/generator/config/search/near.yaml +++ b/generator/config/search/near.yaml @@ -46,7 +46,7 @@ tests: index: releaseddate near: path: released - origin: !bson_utcdatetime '1915-09-13T00:00:00.000+00:00' + origin: !bson_utcdatetime '1915-09-13T00:00:00.000Z' pivot: 7776000000 - $limit: 3 - $project: diff --git a/generator/config/search/phrase.yaml b/generator/config/search/phrase.yaml index edf2cfe2c..d2bfe1eb0 100644 --- a/generator/config/search/phrase.yaml +++ b/generator/config/search/phrase.yaml @@ -13,7 +13,7 @@ arguments: - name: query type: - string - - array # of string + - array - name: slop optional: true type: diff --git a/generator/config/search/queryString.yaml b/generator/config/search/queryString.yaml index c19ca1d08..c31bbdbb3 100644 --- a/generator/config/search/queryString.yaml +++ b/generator/config/search/queryString.yaml @@ -4,7 +4,7 @@ link: https://www.mongodb.com/docs/atlas/atlas-search/queryString/ type: - searchOperator encode: object -description: | +description: '' arguments: - name: defaultPath type: @@ -12,9 +12,6 @@ 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 diff --git a/generator/config/search/range.yaml b/generator/config/search/range.yaml index 124aa9688..1a9cc10c5 100644 --- a/generator/config/search/range.yaml +++ b/generator/config/search/range.yaml @@ -90,8 +90,8 @@ tests: - $search: range: path: _id - gte: !bson_objectId '573a1396f29313caabce4a9a' - lte: !bson_objectId '573a1396f29313caabce4ae7' + gte: !bson_objectId 573a1396f29313caabce4a9a + lte: !bson_objectId 573a1396f29313caabce4ae7 - $project: _id: 1 title: 1 diff --git a/generator/config/search/text.yaml b/generator/config/search/text.yaml index 9b215d76e..0e88cad6b 100644 --- a/generator/config/search/text.yaml +++ b/generator/config/search/text.yaml @@ -21,7 +21,7 @@ arguments: - name: matchCriteria optional: true type: - - string # "any" | "all" + - string - name: synonyms optional: true type: diff --git a/generator/config/stage/addFields.yaml b/generator/config/stage/addFields.yaml index 390a5c31b..97a916364 100644 --- a/generator/config/stage/addFields.yaml +++ b/generator/config/stage/addFields.yaml @@ -19,12 +19,9 @@ tests: pipeline: - $addFields: totalHomework: - # The example renders a single value, but the builder generates an array for consistency - # $sum: '$homework' $sum: - $homework totalQuiz: - # $sum: '$quiz' $sum: - $quiz - $addFields: @@ -52,4 +49,4 @@ tests: homework: $concatArrays: - $homework - - [7] + - - 7 diff --git a/generator/config/stage/bucket.yaml b/generator/config/stage/bucket.yaml index 1cbf83246..6c4968dfe 100644 --- a/generator/config/stage/bucket.yaml +++ b/generator/config/stage/bucket.yaml @@ -9,13 +9,13 @@ description: | 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: @@ -30,7 +30,7 @@ arguments: The default value can be of a different type than the entries in boundaries. - 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. diff --git a/generator/config/stage/bucketAuto.yaml b/generator/config/stage/bucketAuto.yaml index f0c993bc1..32402f7c9 100644 --- a/generator/config/stage/bucketAuto.yaml +++ b/generator/config/stage/bucketAuto.yaml @@ -19,7 +19,7 @@ arguments: A positive 32-bit integer that specifies the number of buckets into which input documents are grouped. - 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. diff --git a/generator/config/stage/collStats.yaml b/generator/config/stage/collStats.yaml index b11939e01..f64799103 100644 --- a/generator/config/stage/collStats.yaml +++ b/generator/config/stage/collStats.yaml @@ -17,11 +17,11 @@ arguments: optional: true - name: count type: - - object # empty object + - object optional: true - name: queryExecStats type: - - object # empty object + - object optional: true tests: - name: latencyStats Document diff --git a/generator/config/stage/densify.yaml b/generator/config/stage/densify.yaml index 31dd19a3b..42f55e8c3 100644 --- a/generator/config/stage/densify.yaml +++ b/generator/config/stage/densify.yaml @@ -9,14 +9,14 @@ description: | 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. To specify a in an embedded document or in an array, use dot notation. - name: partitionByFields type: - - array # of string + - array optional: true description: | The field(s) that will be used as the partition keys. diff --git a/generator/config/stage/documents.yaml b/generator/config/stage/documents.yaml index a41816d7a..6f4b6fe29 100644 --- a/generator/config/stage/documents.yaml +++ b/generator/config/stage/documents.yaml @@ -9,7 +9,7 @@ description: | 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 @@ -21,9 +21,9 @@ tests: 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 buckets: 4 diff --git a/generator/config/stage/facet.yaml b/generator/config/stage/facet.yaml index df33b8dc5..54672dfe5 100644 --- a/generator/config/stage/facet.yaml +++ b/generator/config/stage/facet.yaml @@ -17,16 +17,12 @@ tests: pipeline: - $facet: categorizedByTags: - # The builder uses the verbose form of the $unwind operator - # $unwind: '$tags' - $unwind: path: $tags - $sortByCount: $tags categorizedByPrice: - $match: price: - # The example uses an int, but the builder requires a bool - # $exists: 1 $exists: true - $bucket: groupBy: $price diff --git a/generator/config/stage/fill.yaml b/generator/config/stage/fill.yaml index 352cf83cf..c4e686bda 100644 --- a/generator/config/stage/fill.yaml +++ b/generator/config/stage/fill.yaml @@ -9,7 +9,7 @@ description: | arguments: - name: partitionBy type: - - object # of expression + - object - string optional: true description: | @@ -18,7 +18,7 @@ arguments: partitionBy and partitionByFields are mutually exclusive. - 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. @@ -32,7 +32,7 @@ arguments: Specifies the field or fields to sort the documents within each partition. Uses the same syntax as the $sort stage. - 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. diff --git a/generator/config/stage/group.yaml b/generator/config/stage/group.yaml index f6efe0ce1..3033ab2ca 100644 --- a/generator/config/stage/group.yaml +++ b/generator/config/stage/group.yaml @@ -51,8 +51,8 @@ tests: pipeline: - $match: date: - $gte: !bson_utcdatetime '2014-01-01' - $lt: !bson_utcdatetime '2015-01-01' + $gte: !bson_utcdatetime '2014-01-01T00:00:00.000Z' + $lt: !bson_utcdatetime '2015-01-01T00:00:00.000Z' - $group: _id: $dateToString: @@ -99,6 +99,5 @@ tests: $push: $$ROOT - $addFields: totalCopies: - # $sum: '$books.copies' $sum: - $books.copies diff --git a/generator/config/stage/lookup.yaml b/generator/config/stage/lookup.yaml index 0771be1b6..4e8f76399 100644 --- a/generator/config/stage/lookup.yaml +++ b/generator/config/stage/lookup.yaml @@ -29,7 +29,7 @@ arguments: Specifies the field from the documents in the from collection. $lookup performs an equality match on the foreignField to the localField from the input documents. If a document in the from collection does not contain the foreignField, the $lookup treats the value as null for matching purposes. - 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. diff --git a/generator/config/stage/merge.yaml b/generator/config/stage/merge.yaml index 44b65696e..ecba8f381 100644 --- a/generator/config/stage/merge.yaml +++ b/generator/config/stage/merge.yaml @@ -17,7 +17,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. @@ -117,8 +117,8 @@ tests: pipeline: - $match: date: - $gte: !bson_utcdatetime '2019-05-07' - $lt: !bson_utcdatetime '2019-05-08' + $gte: !bson_utcdatetime '2019-05-07T00:00:00.000Z' + $lt: !bson_utcdatetime '2019-05-08T00:00:00.000Z' - $project: _id: $dateToString: diff --git a/generator/config/stage/project.yaml b/generator/config/stage/project.yaml index fb8cad138..da9803c2a 100644 --- a/generator/config/stage/project.yaml +++ b/generator/config/stage/project.yaml @@ -10,7 +10,7 @@ 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 diff --git a/generator/config/stage/replaceRoot.yaml b/generator/config/stage/replaceRoot.yaml index f483b58f7..dc627c311 100644 --- a/generator/config/stage/replaceRoot.yaml +++ b/generator/config/stage/replaceRoot.yaml @@ -25,8 +25,6 @@ tests: - 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 - $match: diff --git a/generator/config/stage/replaceWith.yaml b/generator/config/stage/replaceWith.yaml index 62ba33c13..e14ab6d3c 100644 --- a/generator/config/stage/replaceWith.yaml +++ b/generator/config/stage/replaceWith.yaml @@ -25,8 +25,6 @@ tests: - 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 - $match: diff --git a/generator/config/stage/search.yaml b/generator/config/stage/search.yaml index f38ec4437..359a60365 100644 --- a/generator/config/stage/search.yaml +++ b/generator/config/stage/search.yaml @@ -24,8 +24,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. @@ -86,7 +84,7 @@ tests: - $search: near: path: released - origin: !bson_utcdatetime '2011-09-01T00:00:00.000+00:00' + origin: !bson_utcdatetime '2011-09-01T00:00:00.000Z' pivot: 7776000000 - $project: _id: 0 @@ -174,7 +172,7 @@ tests: - $search: near: path: released - origin: !bson_utcdatetime '2011-09-01T00:00:00.000+00:00' + origin: !bson_utcdatetime '2011-09-01T00:00:00.000Z' pivot: 7776000000 count: type: total diff --git a/generator/config/stage/searchMeta.yaml b/generator/config/stage/searchMeta.yaml index 31b53f427..53c09e6c1 100644 --- a/generator/config/stage/searchMeta.yaml +++ b/generator/config/stage/searchMeta.yaml @@ -72,10 +72,10 @@ tests: 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' + - !bson_utcdatetime '2000-01-01T00:00:00.000Z' + - !bson_utcdatetime '2005-01-01T00:00:00.000Z' + - !bson_utcdatetime '2010-01-01T00:00:00.000Z' + - !bson_utcdatetime '2015-01-01T00:00:00.000Z' default: other - name: Metadata Results link: https://www.mongodb.com/docs/atlas/atlas-search/facet/#examples diff --git a/generator/config/stage/set.yaml b/generator/config/stage/set.yaml index eca5a9446..d77daa841 100644 --- a/generator/config/stage/set.yaml +++ b/generator/config/stage/set.yaml @@ -18,12 +18,9 @@ tests: 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 totalQuiz: - # $sum: '$quiz' $sum: - $quiz - $set: @@ -57,6 +54,5 @@ tests: pipeline: - $set: quizAverage: - # $avg: '$quiz' $avg: - $quiz diff --git a/generator/config/stage/setWindowFields.yaml b/generator/config/stage/setWindowFields.yaml index 2230388d7..168ba8e25 100644 --- a/generator/config/stage/setWindowFields.yaml +++ b/generator/config/stage/setWindowFields.yaml @@ -45,7 +45,6 @@ tests: pipeline: - $setWindowFields: partitionBy: - # $year: '$orderDate' $year: date: $orderDate sortBy: @@ -62,7 +61,6 @@ tests: pipeline: - $setWindowFields: partitionBy: - # $year: '$orderDate' $year: date: $orderDate sortBy: @@ -80,7 +78,6 @@ tests: pipeline: - $setWindowFields: partitionBy: - # $year: '$orderDate' $year: date: $orderDate sortBy: diff --git a/generator/config/stage/sortByCount.yaml b/generator/config/stage/sortByCount.yaml index 378d6c7e3..dae89bf33 100644 --- a/generator/config/stage/sortByCount.yaml +++ b/generator/config/stage/sortByCount.yaml @@ -14,8 +14,6 @@ tests: - 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 - $sortByCount: $tags diff --git a/generator/config/stage/unionWith.yaml b/generator/config/stage/unionWith.yaml index 279f25c80..3cd3ae5db 100644 --- a/generator/config/stage/unionWith.yaml +++ b/generator/config/stage/unionWith.yaml @@ -48,14 +48,10 @@ tests: - 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 - # $unionWith: 'sales_2019' - $unionWith: coll: sales_2019 - # $unionWith: 'sales_2020' - $unionWith: coll: sales_2020 - $group: diff --git a/generator/config/stage/unset.yaml b/generator/config/stage/unset.yaml index c9801552e..141ffd625 100644 --- a/generator/config/stage/unset.yaml +++ b/generator/config/stage/unset.yaml @@ -16,9 +16,6 @@ tests: - 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 - name: Remove Top-Level Fields diff --git a/generator/config/stage/unwind.yaml b/generator/config/stage/unwind.yaml index 3176045f3..6c6641479 100644 --- a/generator/config/stage/unwind.yaml +++ b/generator/config/stage/unwind.yaml @@ -30,8 +30,6 @@ tests: - 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 - name: preserveNullAndEmptyArrays @@ -61,12 +59,8 @@ tests: - 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 - # Example uses the short form, the builder always generates the verbose form - # $unwind: '$items.tags' - $unwind: path: $items.tags - $group: diff --git a/generator/config/stage/vectorSearch.yaml b/generator/config/stage/vectorSearch.yaml index 114b27a2f..51e3e4ed4 100644 --- a/generator/config/stage/vectorSearch.yaml +++ b/generator/config/stage/vectorSearch.yaml @@ -24,7 +24,7 @@ arguments: Indexed vector type field to search. - 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. - name: exact @@ -53,7 +53,7 @@ tests: - $vectorSearch: index: vector_index path: plot_embedding - queryVector: # skip other numbers, not relevant to the test + queryVector: - -0.0016261312 - -0.028070757 - -0.011342932 @@ -75,7 +75,7 @@ tests: $and: - year: $lt: 1975 - queryVector: # skip other numbers, not relevant to the test + queryVector: - 0.02421053 - -0.022372592 - -0.006231137 @@ -94,7 +94,7 @@ tests: - $vectorSearch: index: vector_index path: plot_embedding - queryVector: # skip other numbers, not relevant to the test + queryVector: - -0.006954097 - -0.009932499 - -0.001311474 From cb2571c1ca39f25231c29363396a99ae4de2f493 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 22 May 2025 13:42:50 +0200 Subject: [PATCH 06/16] generate schema for accumulators --- generator/config/accumulator/accumulator.yaml | 28 ++++++++++ generator/config/accumulator/addToSet.yaml | 37 ++++++++++++ generator/config/accumulator/avg.yaml | 37 ++++++++++++ generator/config/accumulator/bottom.yaml | 22 ++++++++ generator/config/accumulator/bottomN.yaml | 33 +++++++++++ generator/config/accumulator/count.yaml | 40 +++++++++++++ .../config/accumulator/covariancePop.yaml | 20 +++++++ .../config/accumulator/covarianceSamp.yaml | 20 +++++++ generator/config/accumulator/denseRank.yaml | 40 +++++++++++++ generator/config/accumulator/derivative.yaml | 11 ++++ .../config/accumulator/documentNumber.yaml | 20 +++++++ .../config/accumulator/expMovingAvg.yaml | 22 ++++++++ generator/config/accumulator/first.yaml | 37 ++++++++++++ generator/config/accumulator/firstN.yaml | 56 +++++++++++++++++++ generator/config/accumulator/integral.yaml | 11 ++++ generator/config/accumulator/last.yaml | 39 ++++++++++++- generator/config/accumulator/lastN.yaml | 44 +++++++++++++++ generator/config/accumulator/linearFill.yaml | 16 ++++++ generator/config/accumulator/locf.yaml | 8 +++ generator/config/accumulator/max.yaml | 37 ++++++++++++ generator/config/accumulator/maxN.yaml | 33 +++++++++++ generator/config/accumulator/median.yaml | 28 ++++++++++ .../config/accumulator/mergeObjects.yaml | 33 +++++++++++ generator/config/accumulator/min.yaml | 37 ++++++++++++ generator/config/accumulator/minN.yaml | 33 +++++++++++ generator/config/accumulator/percentile.yaml | 42 ++++++++++++++ generator/config/accumulator/push.yaml | 37 ++++++++++++ generator/config/accumulator/rank.yaml | 40 +++++++++++++ generator/config/accumulator/shift.yaml | 40 +++++++++++++ generator/config/accumulator/stdDevPop.yaml | 34 +++++++++++ generator/config/accumulator/stdDevSamp.yaml | 31 ++++++++++ generator/config/accumulator/sum.yaml | 37 ++++++++++++ generator/config/accumulator/top.yaml | 22 ++++++++ generator/config/accumulator/topN.yaml | 33 +++++++++++ 34 files changed, 1057 insertions(+), 1 deletion(-) diff --git a/generator/config/accumulator/accumulator.yaml b/generator/config/accumulator/accumulator.yaml index 9757d28f7..8ea0ddad1 100644 --- a/generator/config/accumulator/accumulator.yaml +++ b/generator/config/accumulator/accumulator.yaml @@ -79,6 +79,20 @@ tests: return (state.sum / state.count) } 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 pipeline: @@ -119,3 +133,17 @@ tests: return state.restaurants } 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 5332682d8..c230972e6 100644 --- a/generator/config/accumulator/addToSet.yaml +++ b/generator/config/accumulator/addToSet.yaml @@ -26,6 +26,23 @@ tests: date: $date itemsSold: $addToSet: $item + 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/addToSet/#use-in--setwindowfields-stage pipeline: @@ -40,3 +57,23 @@ tests: 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/avg.yaml b/generator/config/accumulator/avg.yaml index 052e44eb3..ed6b2ef11 100644 --- a/generator/config/accumulator/avg.yaml +++ b/generator/config/accumulator/avg.yaml @@ -25,6 +25,23 @@ tests: - $quantity avgQuantity: $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 pipeline: @@ -39,3 +56,23 @@ tests: 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/bottom.yaml b/generator/config/accumulator/bottom.yaml index d2455dd36..994ffd83b 100644 --- a/generator/config/accumulator/bottom.yaml +++ b/generator/config/accumulator/bottom.yaml @@ -34,6 +34,17 @@ tests: - $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 pipeline: @@ -46,3 +57,14 @@ tests: - $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 c94ad42ac..9ad82267a 100644 --- a/generator/config/accumulator/bottomN.yaml +++ b/generator/config/accumulator/bottomN.yaml @@ -41,6 +41,17 @@ tests: sortBy: score: -1 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 pipeline: @@ -54,6 +65,17 @@ tests: sortBy: score: -1 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 pipeline: @@ -73,3 +95,14 @@ tests: 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 113bc35ba..5e4f137a1 100644 --- a/generator/config/accumulator/count.yaml +++ b/generator/config/accumulator/count.yaml @@ -17,6 +17,26 @@ tests: _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 pipeline: @@ -31,3 +51,23 @@ tests: 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/covariancePop.yaml b/generator/config/accumulator/covariancePop.yaml index df8262335..bbe350042 100644 --- a/generator/config/accumulator/covariancePop.yaml +++ b/generator/config/accumulator/covariancePop.yaml @@ -32,3 +32,23 @@ tests: 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/covarianceSamp.yaml b/generator/config/accumulator/covarianceSamp.yaml index afaf76671..c08b95ce3 100644 --- a/generator/config/accumulator/covarianceSamp.yaml +++ b/generator/config/accumulator/covarianceSamp.yaml @@ -32,3 +32,23 @@ tests: 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/denseRank.yaml b/generator/config/accumulator/denseRank.yaml index 7b8fdd004..ad4fdf953 100644 --- a/generator/config/accumulator/denseRank.yaml +++ b/generator/config/accumulator/denseRank.yaml @@ -18,6 +18,26 @@ tests: 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 pipeline: @@ -28,3 +48,23 @@ tests: 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 b7e427faf..2e07cd0cf 100644 --- a/generator/config/accumulator/derivative.yaml +++ b/generator/config/accumulator/derivative.yaml @@ -40,3 +40,14 @@ tests: - $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 0bde9852f..d185b2ecf 100644 --- a/generator/config/accumulator/documentNumber.yaml +++ b/generator/config/accumulator/documentNumber.yaml @@ -18,3 +18,23 @@ tests: 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 4fd8d9005..a4b43eab2 100644 --- a/generator/config/accumulator/expMovingAvg.yaml +++ b/generator/config/accumulator/expMovingAvg.yaml @@ -39,6 +39,17 @@ tests: $expMovingAvg: 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 pipeline: @@ -51,3 +62,14 @@ tests: $expMovingAvg: 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 daa1e6053..7c5c41bd3 100644 --- a/generator/config/accumulator/first.yaml +++ b/generator/config/accumulator/first.yaml @@ -23,6 +23,23 @@ tests: _id: $item firstSale: $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 pipeline: @@ -37,3 +54,23 @@ tests: 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/firstN.yaml b/generator/config/accumulator/firstN.yaml index 711fe5778..a24282475 100644 --- a/generator/config/accumulator/firstN.yaml +++ b/generator/config/accumulator/firstN.yaml @@ -45,6 +45,18 @@ tests: $firstN: input: $score n: 5 + schema: + TestCollection: + playerId: + types: + - bsonType: String + gameId: + types: + - bsonType: String + score: + types: + - bsonType: Number + - bsonType: 'Null' - 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: @@ -58,6 +70,17 @@ tests: - $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 pipeline: @@ -69,6 +92,17 @@ tests: - $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 pipeline: @@ -82,6 +116,17 @@ tests: - $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 pipeline: @@ -99,3 +144,14 @@ tests: - 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 dcfe55a07..1d5463b07 100644 --- a/generator/config/accumulator/integral.yaml +++ b/generator/config/accumulator/integral.yaml @@ -37,3 +37,14 @@ tests: - 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 f4cfeca0b..39b6b4efb 100644 --- a/generator/config/accumulator/last.yaml +++ b/generator/config/accumulator/last.yaml @@ -14,7 +14,7 @@ arguments: - expression tests: - name: Use in $group Stage - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/ + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/#use-in--group-stage pipeline: - $sort: item: 1 @@ -23,6 +23,23 @@ tests: _id: $item lastSalesDate: $last: $date + schema: + sales: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + date: + types: + - bsonType: Date + price: + types: + - bsonType: Number + quantity: + types: + - bsonType: Number - name: Use in $setWindowFields Stage link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/#use-in--setwindowfields-stage pipeline: @@ -37,3 +54,23 @@ tests: documents: - 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 befdaa844..8beccf112 100644 --- a/generator/config/accumulator/lastN.yaml +++ b/generator/config/accumulator/lastN.yaml @@ -34,6 +34,17 @@ tests: - $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 pipeline: @@ -45,6 +56,17 @@ tests: - $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 pipeline: @@ -58,6 +80,17 @@ tests: - $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 pipeline: @@ -75,3 +108,14 @@ tests: - 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 b9b972ed7..3fee6d4da 100644 --- a/generator/config/accumulator/linearFill.yaml +++ b/generator/config/accumulator/linearFill.yaml @@ -22,6 +22,14 @@ tests: output: 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 pipeline: @@ -33,3 +41,11 @@ tests: $linearFill: $price locfPrice: $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 3bb20c821..0478e41bb 100644 --- a/generator/config/accumulator/locf.yaml +++ b/generator/config/accumulator/locf.yaml @@ -22,3 +22,11 @@ tests: output: 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 ce07e72de..2698af79b 100644 --- a/generator/config/accumulator/max.yaml +++ b/generator/config/accumulator/max.yaml @@ -25,6 +25,23 @@ tests: - $quantity maxQuantity: $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 pipeline: @@ -39,3 +56,23 @@ tests: 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/maxN.yaml b/generator/config/accumulator/maxN.yaml index c1d7f7c82..38300fb6e 100644 --- a/generator/config/accumulator/maxN.yaml +++ b/generator/config/accumulator/maxN.yaml @@ -32,6 +32,17 @@ tests: - $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 pipeline: @@ -43,6 +54,17 @@ tests: - $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 pipeline: @@ -62,3 +84,14 @@ tests: - 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 1e7a459e6..47af1feea 100644 --- a/generator/config/accumulator/median.yaml +++ b/generator/config/accumulator/median.yaml @@ -33,6 +33,20 @@ tests: $median: 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 pipeline: @@ -52,3 +66,17 @@ 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 2b994f16e..9aeaeed2d 100644 --- a/generator/config/accumulator/mergeObjects.yaml +++ b/generator/config/accumulator/mergeObjects.yaml @@ -20,3 +20,36 @@ tests: _id: $item mergedSales: $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 437607303..569ac11f6 100644 --- a/generator/config/accumulator/min.yaml +++ b/generator/config/accumulator/min.yaml @@ -20,6 +20,23 @@ tests: _id: $item minQuantity: $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 pipeline: @@ -34,3 +51,23 @@ tests: 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/minN.yaml b/generator/config/accumulator/minN.yaml index 58b3286bf..f7d29b080 100644 --- a/generator/config/accumulator/minN.yaml +++ b/generator/config/accumulator/minN.yaml @@ -32,6 +32,17 @@ tests: - $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 pipeline: @@ -43,6 +54,17 @@ tests: - $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 pipeline: @@ -62,3 +84,14 @@ tests: - 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 a043a468c..1775bec3b 100644 --- a/generator/config/accumulator/percentile.yaml +++ b/generator/config/accumulator/percentile.yaml @@ -41,6 +41,20 @@ tests: p: - 0.95 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 pipeline: @@ -82,6 +96,20 @@ tests: - 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 pipeline: @@ -103,3 +131,17 @@ 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 c2e4f041b..178915048 100644 --- a/generator/config/accumulator/push.yaml +++ b/generator/config/accumulator/push.yaml @@ -31,6 +31,23 @@ tests: $push: 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 pipeline: @@ -45,3 +62,23 @@ tests: 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 c426d9a58..e7f9e9dc0 100644 --- a/generator/config/accumulator/rank.yaml +++ b/generator/config/accumulator/rank.yaml @@ -18,6 +18,26 @@ tests: 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 pipeline: @@ -28,3 +48,23 @@ tests: 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 e0f033b59..7e474b496 100644 --- a/generator/config/accumulator/shift.yaml +++ b/generator/config/accumulator/shift.yaml @@ -43,6 +43,26 @@ tests: output: $quantity by: 1 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 pipeline: @@ -56,3 +76,23 @@ tests: output: $quantity by: -1 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 2ba781a15..8efd38b67 100644 --- a/generator/config/accumulator/stdDevPop.yaml +++ b/generator/config/accumulator/stdDevPop.yaml @@ -21,6 +21,20 @@ tests: _id: $quiz stdDev: $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 pipeline: @@ -35,3 +49,23 @@ tests: 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 6ee7a4e3e..920be3833 100644 --- a/generator/config/accumulator/stdDevSamp.yaml +++ b/generator/config/accumulator/stdDevSamp.yaml @@ -23,6 +23,17 @@ tests: _id: ~ ageStdDev: $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 pipeline: @@ -37,3 +48,23 @@ tests: 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 85b4873f0..e31b8ca0e 100644 --- a/generator/config/accumulator/sum.yaml +++ b/generator/config/accumulator/sum.yaml @@ -31,6 +31,23 @@ tests: - $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 pipeline: @@ -45,3 +62,23 @@ tests: 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/top.yaml b/generator/config/accumulator/top.yaml index 19de8e0ab..4d3205b96 100644 --- a/generator/config/accumulator/top.yaml +++ b/generator/config/accumulator/top.yaml @@ -34,6 +34,17 @@ tests: - $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 pipeline: @@ -46,3 +57,14 @@ tests: - $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 255362db8..d2ab525b2 100644 --- a/generator/config/accumulator/topN.yaml +++ b/generator/config/accumulator/topN.yaml @@ -40,6 +40,17 @@ tests: sortBy: score: -1 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 pipeline: @@ -53,6 +64,17 @@ tests: sortBy: score: -1 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 pipeline: @@ -72,3 +94,14 @@ tests: else: 3 sortBy: score: -1 + schema: + gamescores: + playerId: + types: + - bsonType: String + gameId: + types: + - bsonType: String + score: + types: + - bsonType: Number From e28803d058e72019b5fbdd7304d311aca258c302 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 22 May 2025 16:25:39 +0200 Subject: [PATCH 07/16] add test schemas for expressions --- generator/config/expression/abs.yaml | 11 ++ generator/config/expression/acos.yaml | 14 ++ generator/config/expression/acosh.yaml | 8 ++ generator/config/expression/add.yaml | 34 +++++ .../config/expression/allElementsTrue.yaml | 18 +++ generator/config/expression/and.yaml | 14 ++ .../config/expression/anyElementTrue.yaml | 18 +++ generator/config/expression/arrayElemAt.yaml | 13 ++ .../config/expression/arrayToObject.yaml | 46 +++++++ generator/config/expression/asin.yaml | 14 ++ generator/config/expression/asinh.yaml | 8 ++ generator/config/expression/atan.yaml | 14 ++ generator/config/expression/atan2.yaml | 14 ++ generator/config/expression/atanh.yaml | 8 ++ generator/config/expression/avg.yaml | 21 +++ generator/config/expression/binarySize.yaml | 11 ++ generator/config/expression/bitAnd.yaml | 22 ++++ generator/config/expression/bitNot.yaml | 11 ++ generator/config/expression/bitOr.yaml | 22 ++++ generator/config/expression/bitXor.yaml | 11 ++ generator/config/expression/bsonSize.yaml | 102 +++++++++++++++ generator/config/expression/ceil.yaml | 8 ++ generator/config/expression/cmp.yaml | 14 ++ generator/config/expression/concat.yaml | 17 ++- generator/config/expression/concatArrays.yaml | 15 +++ generator/config/expression/cond.yaml | 11 ++ generator/config/expression/convert.yaml | 16 +++ generator/config/expression/cos.yaml | 11 ++ generator/config/expression/cosh.yaml | 8 ++ generator/config/expression/dateAdd.yaml | 27 ++++ generator/config/expression/dateDiff.yaml | 33 +++++ .../config/expression/dateFromParts.yaml | 5 + .../config/expression/dateFromString.yaml | 37 ++++++ generator/config/expression/dateSubtract.yaml | 33 +++++ generator/config/expression/dateToParts.yaml | 17 +++ generator/config/expression/dateToString.yaml | 17 +++ generator/config/expression/dateTrunc.yaml | 40 ++++++ generator/config/expression/dayOfMonth.yaml | 17 +++ generator/config/expression/dayOfWeek.yaml | 17 +++ generator/config/expression/dayOfYear.yaml | 17 +++ .../config/expression/degreesToRadians.yaml | 11 ++ generator/config/expression/divide.yaml | 16 ++- generator/config/expression/eq.yaml | 14 ++ generator/config/expression/exp.yaml | 11 ++ generator/config/expression/filter.yaml | 84 ++++++++++-- generator/config/expression/first.yaml | 1 + generator/config/expression/firstN.yaml | 22 +++- generator/config/expression/floor.yaml | 8 ++ generator/config/expression/function.yaml | 26 ++++ generator/config/expression/getField.yaml | 52 ++++++++ generator/config/expression/gt.yaml | 14 ++ generator/config/expression/gte.yaml | 14 ++ generator/config/expression/hour.yaml | 17 +++ generator/config/expression/ifNull.yaml | 30 +++++ generator/config/expression/in.yaml | 13 ++ generator/config/expression/indexOfArray.yaml | 16 +++ generator/config/expression/indexOfBytes.yaml | 12 ++ generator/config/expression/indexOfCP.yaml | 12 ++ generator/config/expression/isArray.yaml | 15 +++ generator/config/expression/isNumber.yaml | 30 +++++ generator/config/expression/isoDayOfWeek.yaml | 11 ++ generator/config/expression/isoWeek.yaml | 11 ++ generator/config/expression/isoWeekYear.yaml | 8 ++ generator/config/expression/last.yaml | 1 + generator/config/expression/lastN.yaml | 24 +++- generator/config/expression/let.yaml | 14 ++ generator/config/expression/ln.yaml | 11 ++ generator/config/expression/log.yaml | 8 ++ generator/config/expression/log10.yaml | 8 ++ generator/config/expression/lt.yaml | 14 ++ generator/config/expression/lte.yaml | 14 ++ generator/config/expression/ltrim.yaml | 15 +++ generator/config/expression/map.yaml | 27 ++++ generator/config/expression/max.yaml | 21 +++ generator/config/expression/maxN.yaml | 12 ++ generator/config/expression/median.yaml | 14 ++ generator/config/expression/mergeObjects.yaml | 14 ++ generator/config/expression/meta.yaml | 22 ++++ generator/config/expression/millisecond.yaml | 17 +++ generator/config/expression/min.yaml | 21 +++ generator/config/expression/minN.yaml | 12 ++ generator/config/expression/minute.yaml | 17 +++ generator/config/expression/mod.yaml | 14 ++ generator/config/expression/month.yaml | 17 +++ generator/config/expression/multiply.yaml | 17 +++ generator/config/expression/ne.yaml | 14 ++ generator/config/expression/not.yaml | 14 ++ .../config/expression/objectToArray.yaml | 42 ++++++ generator/config/expression/or.yaml | 14 ++ generator/config/expression/percentile.yaml | 14 ++ generator/config/expression/pow.yaml | 20 +++ .../config/expression/radiansToDegrees.yaml | 11 ++ generator/config/expression/rand.yaml | 25 ++++ generator/config/expression/range.yaml | 11 ++ generator/config/expression/reduce.yaml | 90 +++++++++++++ generator/config/expression/regexFind.yaml | 16 +++ generator/config/expression/regexFindAll.yaml | 32 +++++ generator/config/expression/regexMatch.yaml | 24 ++++ generator/config/expression/replaceAll.yaml | 8 ++ generator/config/expression/replaceOne.yaml | 8 ++ generator/config/expression/reverseArray.yaml | 13 ++ generator/config/expression/round.yaml | 17 ++- generator/config/expression/rtrim.yaml | 15 +++ generator/config/expression/second.yaml | 17 +++ .../config/expression/setDifference.yaml | 18 +++ generator/config/expression/setEquals.yaml | 15 +++ generator/config/expression/setField.yaml | 84 ++++++++++++ .../config/expression/setIntersection.yaml | 42 ++++++ generator/config/expression/setIsSubset.yaml | 18 +++ generator/config/expression/setUnion.yaml | 18 +++ generator/config/expression/sin.yaml | 11 ++ generator/config/expression/sinh.yaml | 8 ++ generator/config/expression/size.yaml | 17 +++ generator/config/expression/slice.yaml | 13 ++ generator/config/expression/sortArray.yaml | 120 ++++++++++++++++++ generator/config/expression/split.yaml | 11 ++ generator/config/expression/sqrt.yaml | 25 ++++ generator/config/expression/stdDevPop.yaml | 20 +++ generator/config/expression/strLenBytes.yaml | 8 ++ generator/config/expression/strLenCP.yaml | 8 ++ generator/config/expression/strcasecmp.yaml | 15 +++ generator/config/expression/substr.yaml | 15 +++ generator/config/expression/substrBytes.yaml | 23 ++++ generator/config/expression/substrCP.yaml | 23 ++++ generator/config/expression/subtract.yaml | 60 +++++++++ generator/config/expression/sum.yaml | 21 +++ generator/config/expression/switch.yaml | 13 ++ generator/config/expression/tan.yaml | 11 ++ generator/config/expression/tanh.yaml | 8 ++ generator/config/expression/toBool.yaml | 16 +++ generator/config/expression/toDate.yaml | 18 +++ generator/config/expression/toDecimal.yaml | 16 +++ generator/config/expression/toDouble.yaml | 11 ++ .../config/expression/toHashedIndexKey.yaml | 5 + generator/config/expression/toInt.yaml | 16 +++ generator/config/expression/toLong.yaml | 13 ++ generator/config/expression/toLower.yaml | 15 +++ generator/config/expression/toObjectId.yaml | 12 ++ generator/config/expression/toString.yaml | 15 +++ generator/config/expression/toUpper.yaml | 15 +++ generator/config/expression/trim.yaml | 15 +++ generator/config/expression/trunc.yaml | 8 ++ generator/config/expression/tsIncrement.yaml | 22 ++++ generator/config/expression/tsSecond.yaml | 22 ++++ generator/config/expression/type.yaml | 24 ++++ generator/config/expression/unsetField.yaml | 49 +++++++ generator/config/expression/week.yaml | 17 +++ generator/config/expression/year.yaml | 17 +++ generator/config/expression/zip.yaml | 26 ++++ 149 files changed, 2930 insertions(+), 28 deletions(-) diff --git a/generator/config/expression/abs.yaml b/generator/config/expression/abs.yaml index 657769bb8..e610b1eba 100644 --- a/generator/config/expression/abs.yaml +++ b/generator/config/expression/abs.yaml @@ -20,3 +20,14 @@ tests: $subtract: - $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 1f80bfa50..2b2004623 100644 --- a/generator/config/expression/acos.yaml +++ b/generator/config/expression/acos.yaml @@ -26,3 +26,17 @@ tests: $divide: - $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 cfa764338..cd0510226 100644 --- a/generator/config/expression/acosh.yaml +++ b/generator/config/expression/acosh.yaml @@ -23,3 +23,11 @@ tests: y-coordinate: $radiansToDegrees: $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 047be409d..a2471af23 100644 --- a/generator/config/expression/add.yaml +++ b/generator/config/expression/add.yaml @@ -28,6 +28,23 @@ tests: $add: - $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 pipeline: @@ -37,3 +54,20 @@ tests: $add: - $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 13b4cc4a0..dfdcbf3c6 100644 --- a/generator/config/expression/allElementsTrue.yaml +++ b/generator/config/expression/allElementsTrue.yaml @@ -20,3 +20,21 @@ tests: $allElementsTrue: - $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 94b1b32bf..a0f516e20 100644 --- a/generator/config/expression/and.yaml +++ b/generator/config/expression/and.yaml @@ -30,3 +30,17 @@ tests: - $lt: - $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 545a39c95..ba3ef49af 100644 --- a/generator/config/expression/anyElementTrue.yaml +++ b/generator/config/expression/anyElementTrue.yaml @@ -20,3 +20,21 @@ tests: $anyElementTrue: - $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 13b65c73c..da290621c 100644 --- a/generator/config/expression/arrayElemAt.yaml +++ b/generator/config/expression/arrayElemAt.yaml @@ -27,3 +27,16 @@ tests: $arrayElemAt: - $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 596b8e32e..203ab7968 100644 --- a/generator/config/expression/arrayToObject.yaml +++ b/generator/config/expression/arrayToObject.yaml @@ -19,6 +19,31 @@ tests: dimensions: $arrayToObject: - $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 pipeline: @@ -37,3 +62,24 @@ tests: instock: $arrayToObject: - $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 0ea55e84f..2c0f05064 100644 --- a/generator/config/expression/asin.yaml +++ b/generator/config/expression/asin.yaml @@ -26,3 +26,17 @@ tests: $divide: - $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 89a984399..9870a9ee5 100644 --- a/generator/config/expression/asinh.yaml +++ b/generator/config/expression/asinh.yaml @@ -23,3 +23,11 @@ tests: y-coordinate: $radiansToDegrees: $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 4126ec805..242209a26 100644 --- a/generator/config/expression/atan.yaml +++ b/generator/config/expression/atan.yaml @@ -26,3 +26,17 @@ tests: $divide: - $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 38e7f6615..38b1c5cf4 100644 --- a/generator/config/expression/atan2.yaml +++ b/generator/config/expression/atan2.yaml @@ -28,3 +28,17 @@ tests: $atan2: - $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 5d83baaa6..dba39aa30 100644 --- a/generator/config/expression/atanh.yaml +++ b/generator/config/expression/atanh.yaml @@ -23,3 +23,11 @@ tests: y-coordinate: $radiansToDegrees: $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 62ff078b3..718b94ff1 100644 --- a/generator/config/expression/avg.yaml +++ b/generator/config/expression/avg.yaml @@ -27,3 +27,24 @@ tests: $avg: - $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 4acb7b24d..f74f4c51d 100644 --- a/generator/config/expression/binarySize.yaml +++ b/generator/config/expression/binarySize.yaml @@ -20,3 +20,14 @@ tests: name: $name imageSize: $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 5b04a1d8e..e40c79ee5 100644 --- a/generator/config/expression/bitAnd.yaml +++ b/generator/config/expression/bitAnd.yaml @@ -23,6 +23,17 @@ tests: $bitAnd: - $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 pipeline: @@ -31,3 +42,14 @@ tests: $bitAnd: - $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 d43b7b013..99de490e0 100644 --- a/generator/config/expression/bitNot.yaml +++ b/generator/config/expression/bitNot.yaml @@ -20,3 +20,14 @@ tests: - $project: result: $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 7c11de1b4..f5c4c504b 100644 --- a/generator/config/expression/bitOr.yaml +++ b/generator/config/expression/bitOr.yaml @@ -23,6 +23,17 @@ tests: $bitOr: - $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 pipeline: @@ -31,3 +42,14 @@ tests: $bitOr: - $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 2669607fb..ff5f72813 100644 --- a/generator/config/expression/bitXor.yaml +++ b/generator/config/expression/bitXor.yaml @@ -23,3 +23,14 @@ tests: $bitXor: - $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 2a3617ec4..a4fe1d7c3 100644 --- a/generator/config/expression/bsonSize.yaml +++ b/generator/config/expression/bsonSize.yaml @@ -19,6 +19,40 @@ tests: name: 1 object_size: $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 pipeline: @@ -27,6 +61,40 @@ tests: combined_object_size: $sum: $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 pipeline: @@ -37,3 +105,37 @@ tests: - $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/ceil.yaml b/generator/config/expression/ceil.yaml index 31a060d52..624907476 100644 --- a/generator/config/expression/ceil.yaml +++ b/generator/config/expression/ceil.yaml @@ -20,3 +20,11 @@ tests: value: 1 ceilingValue: $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 6125fe27c..718a9dc8c 100644 --- a/generator/config/expression/cmp.yaml +++ b/generator/config/expression/cmp.yaml @@ -25,3 +25,17 @@ tests: - $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 d43aef1b5..67cc439a0 100644 --- a/generator/config/expression/concat.yaml +++ b/generator/config/expression/concat.yaml @@ -13,7 +13,7 @@ arguments: variadic: array tests: - name: Example - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/#examples + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/#example pipeline: - $project: itemDescription: @@ -21,3 +21,18 @@ tests: - $item - ' - ' - $description + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + quarter: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' diff --git a/generator/config/expression/concatArrays.yaml b/generator/config/expression/concatArrays.yaml index 0a90614e1..23be611cf 100644 --- a/generator/config/expression/concatArrays.yaml +++ b/generator/config/expression/concatArrays.yaml @@ -20,3 +20,18 @@ tests: $concatArrays: - $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 2512737f5..e968a2847 100644 --- a/generator/config/expression/cond.yaml +++ b/generator/config/expression/cond.yaml @@ -30,3 +30,14 @@ tests: - 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 84a4e90db..a136bfdd1 100644 --- a/generator/config/expression/convert.yaml +++ b/generator/config/expression/convert.yaml @@ -68,3 +68,19 @@ tests: $multiply: - $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 bcd35d042..d67ab659d 100644 --- a/generator/config/expression/cos.yaml +++ b/generator/config/expression/cos.yaml @@ -24,3 +24,14 @@ tests: - $cos: $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 73a02a01d..471266636 100644 --- a/generator/config/expression/cosh.yaml +++ b/generator/config/expression/cosh.yaml @@ -22,3 +22,11 @@ tests: cosh_output: $cosh: $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 5a17fe87f..224def6ec 100644 --- a/generator/config/expression/dateAdd.yaml +++ b/generator/config/expression/dateAdd.yaml @@ -41,6 +41,14 @@ tests: amount: 3 - $merge: 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 pipeline: @@ -63,6 +71,14 @@ tests: $dateToString: format: '%Y-%m-%d' 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 pipeline: @@ -116,3 +132,14 @@ tests: amount: 24 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 c001a11d6..1ed98da05 100644 --- a/generator/config/expression/dateDiff.yaml +++ b/generator/config/expression/dateDiff.yaml @@ -56,6 +56,17 @@ tests: $trunc: - $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 pipeline: @@ -78,6 +89,17 @@ tests: 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 pipeline: @@ -100,3 +122,14 @@ tests: 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 b1beaf91a..c9c181ee9 100644 --- a/generator/config/expression/dateFromParts.yaml +++ b/generator/config/expression/dateFromParts.yaml @@ -99,3 +99,8 @@ tests: minute: 46 second: 12 timezone: America/New_York + schema: + sales: + _id: + types: + - bsonType: ObjectId diff --git a/generator/config/expression/dateFromString.yaml b/generator/config/expression/dateFromString.yaml index 1a88431c9..2ae84bb50 100644 --- a/generator/config/expression/dateFromString.yaml +++ b/generator/config/expression/dateFromString.yaml @@ -48,6 +48,20 @@ tests: $dateFromString: 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 pipeline: @@ -57,6 +71,17 @@ tests: 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 pipeline: @@ -66,3 +91,15 @@ tests: dateString: $date timezone: $timezone onNull: !bson_utcdatetime '0' + 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 5a97f45d6..11c97f661 100644 --- a/generator/config/expression/dateSubtract.yaml +++ b/generator/config/expression/dateSubtract.yaml @@ -47,6 +47,17 @@ tests: amount: 3 - $merge: 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 pipeline: @@ -65,6 +76,17 @@ tests: $dateToString: format: '%Y-%m-%d' 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 pipeline: @@ -118,3 +140,14 @@ tests: amount: 24 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 ea77f7dcd..2e281ce33 100644 --- a/generator/config/expression/dateToParts.yaml +++ b/generator/config/expression/dateToParts.yaml @@ -42,3 +42,20 @@ tests: $dateToParts: 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 241db86a3..d0199da02 100644 --- a/generator/config/expression/dateToString.yaml +++ b/generator/config/expression/dateToString.yaml @@ -73,3 +73,20 @@ tests: format: '%B' 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 ae42a0982..e89c94e6d 100644 --- a/generator/config/expression/dateTrunc.yaml +++ b/generator/config/expression/dateTrunc.yaml @@ -54,6 +54,26 @@ tests: binSize: 2 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 pipeline: @@ -66,3 +86,23 @@ tests: binSize: 6 sumQuantity: $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 a6e22b980..17582c872 100644 --- a/generator/config/expression/dayOfMonth.yaml +++ b/generator/config/expression/dayOfMonth.yaml @@ -28,3 +28,20 @@ tests: day: $dayOfMonth: 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 1f2e84134..5b74b648d 100644 --- a/generator/config/expression/dayOfWeek.yaml +++ b/generator/config/expression/dayOfWeek.yaml @@ -28,3 +28,20 @@ tests: dayOfWeek: $dayOfWeek: 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 ed529158f..12c78c151 100644 --- a/generator/config/expression/dayOfYear.yaml +++ b/generator/config/expression/dayOfYear.yaml @@ -28,3 +28,20 @@ tests: dayOfYear: $dayOfYear: 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 bd2257f5c..d224764cf 100644 --- a/generator/config/expression/degreesToRadians.yaml +++ b/generator/config/expression/degreesToRadians.yaml @@ -25,3 +25,14 @@ tests: $degreesToRadians: $angle_b angle_c_rad: $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 880a3ba2e..3a2eeba4b 100644 --- a/generator/config/expression/divide.yaml +++ b/generator/config/expression/divide.yaml @@ -17,7 +17,7 @@ arguments: - resolvesToNumber tests: - name: Example - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/#example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/#examples pipeline: - $project: city: 1 @@ -25,3 +25,17 @@ tests: $divide: - $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 9ffdaa477..ac84de381 100644 --- a/generator/config/expression/eq.yaml +++ b/generator/config/expression/eq.yaml @@ -25,3 +25,17 @@ tests: - $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 73b70a724..5948e8b52 100644 --- a/generator/config/expression/exp.yaml +++ b/generator/config/expression/exp.yaml @@ -19,3 +19,14 @@ tests: $subtract: - $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 43b9964a8..aff690085 100644 --- a/generator/config/expression/filter.yaml +++ b/generator/config/expression/filter.yaml @@ -41,8 +41,31 @@ tests: $gte: - $$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 + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#use-the-limit-field pipeline: - $project: items: @@ -54,19 +77,29 @@ tests: - 100 as: item limit: 1 - - name: limit as a Numeric Expression - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/#limit-as-a-numeric-expression - pipeline: - - $project: - items: - $filter: - input: $items - cond: - $lte: - - $$item.price - - 150 - as: item - limit: 2 + 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 pipeline: @@ -80,3 +113,26 @@ tests: - 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 diff --git a/generator/config/expression/first.yaml b/generator/config/expression/first.yaml index 56c5be2ad..caf5ed2ca 100644 --- a/generator/config/expression/first.yaml +++ b/generator/config/expression/first.yaml @@ -16,3 +16,4 @@ tests: - $addFields: firstItem: $first: $items + schema: '// TODO: No docs reference found' diff --git a/generator/config/expression/firstN.yaml b/generator/config/expression/firstN.yaml index d38727b94..8ef25a8f4 100644 --- a/generator/config/expression/firstN.yaml +++ b/generator/config/expression/firstN.yaml @@ -19,13 +19,26 @@ arguments: 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 + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/#example pipeline: - $addFields: firstScores: $firstN: n: 3 input: $score + schema: + games: + playerId: + types: + - bsonType: Number + score: + types: + - bsonType: Array + types: + - bsonType: Number + - bsonType: 'Null' + - bsonType: String + - bsonType: Long - 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: @@ -40,3 +53,10 @@ tests: $firstN: input: $array n: 3 + schema: + TestCollection: + array: + types: + - bsonType: Array + types: + - bsonType: Number diff --git a/generator/config/expression/floor.yaml b/generator/config/expression/floor.yaml index 171c622b5..8782619c0 100644 --- a/generator/config/expression/floor.yaml +++ b/generator/config/expression/floor.yaml @@ -18,3 +18,11 @@ tests: value: 1 floorValue: $floor: $value + schema: + samples: + _id: + types: + - bsonType: Number + value: + types: + - bsonType: Number diff --git a/generator/config/expression/function.yaml b/generator/config/expression/function.yaml index daf6b7b90..0f4394627 100644 --- a/generator/config/expression/function.yaml +++ b/generator/config/expression/function.yaml @@ -51,6 +51,19 @@ tests: - $name - $scores lang: js + schema: + players: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + scores: + types: + - bsonType: Array + types: + - bsonType: Number - name: Alternative to $where link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/#example-2--alternative-to--where pipeline: @@ -65,3 +78,16 @@ tests: args: - $name lang: js + schema: + players: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + scores: + types: + - bsonType: Array + types: + - bsonType: Number diff --git a/generator/config/expression/getField.yaml b/generator/config/expression/getField.yaml index c515a6a2a..dde646964 100644 --- a/generator/config/expression/getField.yaml +++ b/generator/config/expression/getField.yaml @@ -31,6 +31,20 @@ tests: - $getField: field: price.usd - 200 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price.usd: + types: + - bsonType: Number + qty: + types: + - bsonType: Number - 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: @@ -41,6 +55,20 @@ tests: field: $literal: $price - 200 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + $price: + types: + - bsonType: Number + qty: + types: + - bsonType: Number - 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: @@ -52,3 +80,27 @@ tests: $literal: $small input: $quantity - 20 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price.usd: + types: + - bsonType: Number + quantity: + types: + - bsonType: Document + fields: + $large: + types: + - bsonType: Number + $medium: + types: + - bsonType: Number + $small: + types: + - bsonType: Number diff --git a/generator/config/expression/gt.yaml b/generator/config/expression/gt.yaml index 0f0fdcfc6..d0f7375a3 100644 --- a/generator/config/expression/gt.yaml +++ b/generator/config/expression/gt.yaml @@ -25,3 +25,17 @@ tests: - $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/gte.yaml b/generator/config/expression/gte.yaml index 5da36026b..3cac1340f 100644 --- a/generator/config/expression/gte.yaml +++ b/generator/config/expression/gte.yaml @@ -25,3 +25,17 @@ tests: - $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/hour.yaml b/generator/config/expression/hour.yaml index b30a02576..2de86625a 100644 --- a/generator/config/expression/hour.yaml +++ b/generator/config/expression/hour.yaml @@ -28,3 +28,20 @@ tests: hour: $hour: 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/ifNull.yaml b/generator/config/expression/ifNull.yaml index 40b9b464c..45105d813 100644 --- a/generator/config/expression/ifNull.yaml +++ b/generator/config/expression/ifNull.yaml @@ -21,6 +21,21 @@ tests: $ifNull: - $description - Unspecified + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' + quantity: + types: + - bsonType: Number - name: Multiple Input Expressions link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/#multiple-input-expressions pipeline: @@ -31,3 +46,18 @@ tests: - $description - $quantity - Unspecified + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' + quantity: + types: + - bsonType: Number diff --git a/generator/config/expression/in.yaml b/generator/config/expression/in.yaml index 20e4390dc..f3cb996ed 100644 --- a/generator/config/expression/in.yaml +++ b/generator/config/expression/in.yaml @@ -27,3 +27,16 @@ tests: $in: - bananas - $in_stock + schema: + TestCollection: + _id: + types: + - bsonType: Number + location: + types: + - bsonType: String + in_stock: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/expression/indexOfArray.yaml b/generator/config/expression/indexOfArray.yaml index 1f8fb45c5..7d4726f95 100644 --- a/generator/config/expression/indexOfArray.yaml +++ b/generator/config/expression/indexOfArray.yaml @@ -40,3 +40,19 @@ tests: $indexOfArray: - $items - 2 + schema: + inventory: + _id: + types: + - bsonType: Number + items: + types: + - bsonType: Array + types: + - bsonType: Number + - bsonType: 'Null' + - bsonType: String + - bsonType: 'Null' + amount: + types: + - bsonType: Number diff --git a/generator/config/expression/indexOfBytes.yaml b/generator/config/expression/indexOfBytes.yaml index 0c6f4300f..a940a738c 100644 --- a/generator/config/expression/indexOfBytes.yaml +++ b/generator/config/expression/indexOfBytes.yaml @@ -42,3 +42,15 @@ tests: $indexOfBytes: - $item - foo + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + - bsonType: 'Null' + amount: + types: + - bsonType: Number diff --git a/generator/config/expression/indexOfCP.yaml b/generator/config/expression/indexOfCP.yaml index 025ef26c8..0af45c319 100644 --- a/generator/config/expression/indexOfCP.yaml +++ b/generator/config/expression/indexOfCP.yaml @@ -42,3 +42,15 @@ tests: $indexOfCP: - $item - foo + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + - bsonType: 'Null' + amount: + types: + - bsonType: Number diff --git a/generator/config/expression/isArray.yaml b/generator/config/expression/isArray.yaml index 3fedc269a..4f42cabc7 100644 --- a/generator/config/expression/isArray.yaml +++ b/generator/config/expression/isArray.yaml @@ -28,3 +28,18 @@ tests: - $instock - $ordered else: One or more fields is not an array. + 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/isNumber.yaml b/generator/config/expression/isNumber.yaml index 8605b8fbf..f6d3b7682 100644 --- a/generator/config/expression/isNumber.yaml +++ b/generator/config/expression/isNumber.yaml @@ -21,6 +21,21 @@ tests: $isNumber: $reading hasType: $type: $reading + schema: + sensors: + _id: + types: + - bsonType: Number + reading: + types: + - bsonType: Decimal128 + - bsonType: Long + - bsonType: Int32 + - bsonType: Number + - bsonType: String + - bsonType: Array + types: + - bsonType: Decimal128 - name: Conditionally Modify Fields using $isNumber link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/isNumber/#conditionally-modify-fields-using--isnumber pipeline: @@ -62,3 +77,18 @@ tests: _id: $student_id GPA: $avg: $points + schema: + grades: + student_id: + types: + - bsonType: Number + class_id: + types: + - bsonType: String + class_desc: + types: + - bsonType: String + grade: + types: + - bsonType: String + - bsonType: Number diff --git a/generator/config/expression/isoDayOfWeek.yaml b/generator/config/expression/isoDayOfWeek.yaml index 7d8374db2..4f4c1f41d 100644 --- a/generator/config/expression/isoDayOfWeek.yaml +++ b/generator/config/expression/isoDayOfWeek.yaml @@ -30,3 +30,14 @@ tests: dayOfWeek: $isoDayOfWeek: date: $birthday + schema: + birthdays: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + birthday: + types: + - bsonType: Date diff --git a/generator/config/expression/isoWeek.yaml b/generator/config/expression/isoWeek.yaml index f36c5d2e6..d80783d65 100644 --- a/generator/config/expression/isoWeek.yaml +++ b/generator/config/expression/isoWeek.yaml @@ -30,3 +30,14 @@ tests: weekNumber: $isoWeek: date: $date + schema: + deliveries: + _id: + types: + - bsonType: Number + date: + types: + - bsonType: Date + city: + types: + - bsonType: String diff --git a/generator/config/expression/isoWeekYear.yaml b/generator/config/expression/isoWeekYear.yaml index d390f7de2..3c441f887 100644 --- a/generator/config/expression/isoWeekYear.yaml +++ b/generator/config/expression/isoWeekYear.yaml @@ -28,3 +28,11 @@ tests: yearNumber: $isoWeekYear: date: $date + schema: + TestCollection: + _id: + types: + - bsonType: Number + date: + types: + - bsonType: Date diff --git a/generator/config/expression/last.yaml b/generator/config/expression/last.yaml index 4c9ba200f..5f2378a85 100644 --- a/generator/config/expression/last.yaml +++ b/generator/config/expression/last.yaml @@ -16,3 +16,4 @@ tests: - $addFields: lastItem: $last: $items + schema: '// TODO: No docs reference found' diff --git a/generator/config/expression/lastN.yaml b/generator/config/expression/lastN.yaml index b3d0ae031..3e96d5186 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-operator type: - resolvesToArray encode: object @@ -19,13 +19,26 @@ arguments: 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/lastN-array-element/#example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#example pipeline: - $addFields: lastScores: $lastN: n: 3 input: $score + schema: + games: + playerId: + types: + - bsonType: Number + score: + types: + - bsonType: Array + types: + - bsonType: Number + - bsonType: 'Null' + - bsonType: String + - bsonType: Long - 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: @@ -40,3 +53,10 @@ tests: $lastN: input: $array n: 3 + schema: + TestCollection: + array: + types: + - bsonType: Array + types: + - bsonType: Number diff --git a/generator/config/expression/let.yaml b/generator/config/expression/let.yaml index a6285f140..5d7ca6993 100644 --- a/generator/config/expression/let.yaml +++ b/generator/config/expression/let.yaml @@ -40,3 +40,17 @@ tests: $multiply: - $$total - $$discounted + schema: + TestCollection: + _id: + types: + - bsonType: Number + price: + types: + - bsonType: Number + tax: + types: + - bsonType: Number + applyDiscount: + types: + - bsonType: Boolean diff --git a/generator/config/expression/ln.yaml b/generator/config/expression/ln.yaml index 42c28fe28..8f2896eec 100644 --- a/generator/config/expression/ln.yaml +++ b/generator/config/expression/ln.yaml @@ -21,3 +21,14 @@ tests: x: $year y: $ln: $sales + schema: + TestCollection: + _id: + types: + - bsonType: Number + year: + types: + - bsonType: String + sales: + types: + - bsonType: Number diff --git a/generator/config/expression/log.yaml b/generator/config/expression/log.yaml index 7d2bfe3e9..deefa534c 100644 --- a/generator/config/expression/log.yaml +++ b/generator/config/expression/log.yaml @@ -29,3 +29,11 @@ tests: - $log: - $int - 2 + schema: + integers: + _id: + types: + - bsonType: Number + int: + types: + - bsonType: Number diff --git a/generator/config/expression/log10.yaml b/generator/config/expression/log10.yaml index d5ce9faa7..9be981e08 100644 --- a/generator/config/expression/log10.yaml +++ b/generator/config/expression/log10.yaml @@ -21,3 +21,11 @@ tests: $multiply: - -1 - $log10: $H3O + schema: + samples: + _id: + types: + - bsonType: Number + H3O: + types: + - bsonType: Number diff --git a/generator/config/expression/lt.yaml b/generator/config/expression/lt.yaml index 7e0d72c3a..d64831d6d 100644 --- a/generator/config/expression/lt.yaml +++ b/generator/config/expression/lt.yaml @@ -25,3 +25,17 @@ tests: - $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/lte.yaml b/generator/config/expression/lte.yaml index 9d250f4b6..c79ce0163 100644 --- a/generator/config/expression/lte.yaml +++ b/generator/config/expression/lte.yaml @@ -25,3 +25,17 @@ tests: - $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/ltrim.yaml b/generator/config/expression/ltrim.yaml index cc7f2e450..9a0c5705c 100644 --- a/generator/config/expression/ltrim.yaml +++ b/generator/config/expression/ltrim.yaml @@ -30,3 +30,18 @@ tests: description: $ltrim: input: $description + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + quarter: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' diff --git a/generator/config/expression/map.yaml b/generator/config/expression/map.yaml index 152957ecf..d11e26eb3 100644 --- a/generator/config/expression/map.yaml +++ b/generator/config/expression/map.yaml @@ -36,6 +36,13 @@ tests: $add: - $$grade - 2 + schema: + grades: + quizzes: + types: + - bsonType: Array + types: + - bsonType: Number - name: Truncate Each Array Element link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/#truncate-each-array-element pipeline: @@ -48,6 +55,16 @@ tests: in: $trunc: - $$decimalValue + schema: + deliveries: + city: + types: + - bsonType: String + distances: + types: + - bsonType: Array + types: + - bsonType: Number - name: Convert Celsius Temperatures to Fahrenheit link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/#convert-celsius-temperatures-to-fahrenheit pipeline: @@ -62,3 +79,13 @@ tests: - $$tempInCelsius - 1.8 - 32 + schema: + temperatures: + date: + types: + - bsonType: Date + tempsC: + types: + - bsonType: Array + types: + - bsonType: Number diff --git a/generator/config/expression/max.yaml b/generator/config/expression/max.yaml index 2240c43b6..cf38edf95 100644 --- a/generator/config/expression/max.yaml +++ b/generator/config/expression/max.yaml @@ -27,3 +27,24 @@ tests: $max: - $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/maxN.yaml b/generator/config/expression/maxN.yaml index b0a72aa26..24f87372a 100644 --- a/generator/config/expression/maxN.yaml +++ b/generator/config/expression/maxN.yaml @@ -26,3 +26,15 @@ tests: $maxN: n: 2 input: $score + schema: + scores: + playerId: + types: + - bsonType: Number + score: + types: + - bsonType: Array + types: + - bsonType: Number + - bsonType: 'Null' + - bsonType: String diff --git a/generator/config/expression/median.yaml b/generator/config/expression/median.yaml index 6ef1c6425..b286bc921 100644 --- a/generator/config/expression/median.yaml +++ b/generator/config/expression/median.yaml @@ -37,3 +37,17 @@ tests: - $test02 - $test03 method: approximate + schema: + testScores: + studentId: + types: + - bsonType: String + test01: + types: + - bsonType: Number + test02: + types: + - bsonType: Number + test03: + types: + - bsonType: Number diff --git a/generator/config/expression/mergeObjects.yaml b/generator/config/expression/mergeObjects.yaml index c4b9418f4..c56b7fd81 100644 --- a/generator/config/expression/mergeObjects.yaml +++ b/generator/config/expression/mergeObjects.yaml @@ -31,3 +31,17 @@ tests: - $$ROOT - $project: fromItems: 0 + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + ordered: + types: + - bsonType: Number diff --git a/generator/config/expression/meta.yaml b/generator/config/expression/meta.yaml index 9d3a0902f..8e89b7c70 100644 --- a/generator/config/expression/meta.yaml +++ b/generator/config/expression/meta.yaml @@ -22,6 +22,14 @@ tests: $meta: textScore count: $sum: 1 + schema: + articles: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String - name: indexKey link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/#-meta---indexkey- pipeline: @@ -30,3 +38,17 @@ tests: - $addFields: idxKey: $meta: indexKey + schema: + orders: + item: + types: + - bsonType: String + price: + types: + - bsonType: Decimal128 + quantity: + types: + - bsonType: Number + type: + types: + - bsonType: String diff --git a/generator/config/expression/millisecond.yaml b/generator/config/expression/millisecond.yaml index a6200788f..bb186331a 100644 --- a/generator/config/expression/millisecond.yaml +++ b/generator/config/expression/millisecond.yaml @@ -28,3 +28,20 @@ tests: milliseconds: $millisecond: 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/min.yaml b/generator/config/expression/min.yaml index 80fdef1ac..837551f12 100644 --- a/generator/config/expression/min.yaml +++ b/generator/config/expression/min.yaml @@ -27,3 +27,24 @@ tests: $min: - $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/minN.yaml b/generator/config/expression/minN.yaml index e53b3c4b0..a3e5a7558 100644 --- a/generator/config/expression/minN.yaml +++ b/generator/config/expression/minN.yaml @@ -26,3 +26,15 @@ tests: $minN: n: 2 input: $score + schema: + scores: + playerId: + types: + - bsonType: Number + score: + types: + - bsonType: Array + types: + - bsonType: Number + - bsonType: 'Null' + - bsonType: String diff --git a/generator/config/expression/minute.yaml b/generator/config/expression/minute.yaml index 06997a6a0..68a41ea5b 100644 --- a/generator/config/expression/minute.yaml +++ b/generator/config/expression/minute.yaml @@ -28,3 +28,20 @@ tests: minutes: $minute: 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/mod.yaml b/generator/config/expression/mod.yaml index a5740e687..2424d0b78 100644 --- a/generator/config/expression/mod.yaml +++ b/generator/config/expression/mod.yaml @@ -24,3 +24,17 @@ tests: $mod: - $hours - $tasks + schema: + conferencePlanning: + _id: + types: + - bsonType: Number + city: + types: + - bsonType: String + hours: + types: + - bsonType: Number + tasks: + types: + - bsonType: Number diff --git a/generator/config/expression/month.yaml b/generator/config/expression/month.yaml index 51321d3f6..eb03af8e0 100644 --- a/generator/config/expression/month.yaml +++ b/generator/config/expression/month.yaml @@ -28,3 +28,20 @@ tests: month: $month: 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/multiply.yaml b/generator/config/expression/multiply.yaml index d0a107b91..c6713ce76 100644 --- a/generator/config/expression/multiply.yaml +++ b/generator/config/expression/multiply.yaml @@ -25,3 +25,20 @@ tests: $multiply: - $price - $quantity + 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/ne.yaml b/generator/config/expression/ne.yaml index cec84134b..cadd1f3d5 100644 --- a/generator/config/expression/ne.yaml +++ b/generator/config/expression/ne.yaml @@ -25,3 +25,17 @@ tests: - $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/not.yaml b/generator/config/expression/not.yaml index 0b2266e3b..204c10eaf 100644 --- a/generator/config/expression/not.yaml +++ b/generator/config/expression/not.yaml @@ -22,3 +22,17 @@ tests: - $gt: - $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/objectToArray.yaml b/generator/config/expression/objectToArray.yaml index 503a80db6..fe29f98f0 100644 --- a/generator/config/expression/objectToArray.yaml +++ b/generator/config/expression/objectToArray.yaml @@ -20,6 +20,27 @@ tests: item: 1 dimensions: $objectToArray: $dimensions + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + dimensions: + types: + - bsonType: Document + fields: + l: + types: + - bsonType: Number + w: + types: + - bsonType: Number + uom: + types: + - bsonType: String - name: $objectToArray to Sum Nested Fields link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/#-objecttoarray-to-sum-nested-fields pipeline: @@ -32,3 +53,24 @@ tests: _id: $warehouses.k total: $sum: $warehouses.v + 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/or.yaml b/generator/config/expression/or.yaml index d349fcb5b..50146573d 100644 --- a/generator/config/expression/or.yaml +++ b/generator/config/expression/or.yaml @@ -26,3 +26,17 @@ tests: - $lt: - $qty - 200 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + description: + types: + - bsonType: String + qty: + types: + - bsonType: Number diff --git a/generator/config/expression/percentile.yaml b/generator/config/expression/percentile.yaml index 25b9ecbd9..94264a114 100644 --- a/generator/config/expression/percentile.yaml +++ b/generator/config/expression/percentile.yaml @@ -46,3 +46,17 @@ tests: - 0.5 - 0.95 method: approximate + schema: + testScores: + studentId: + types: + - bsonType: String + test01: + types: + - bsonType: Number + test02: + types: + - bsonType: Number + test03: + types: + - bsonType: Number diff --git a/generator/config/expression/pow.yaml b/generator/config/expression/pow.yaml index 7588d3eeb..110a72249 100644 --- a/generator/config/expression/pow.yaml +++ b/generator/config/expression/pow.yaml @@ -23,3 +23,23 @@ tests: - $stdDevPop: - $scores.score - 2 + schema: + quizzes: + _id: + types: + - bsonType: Number + scores: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + score: + types: + - bsonType: Number + quiz: + types: + - bsonType: Number diff --git a/generator/config/expression/radiansToDegrees.yaml b/generator/config/expression/radiansToDegrees.yaml index e24d6bc9a..b33a25aa1 100644 --- a/generator/config/expression/radiansToDegrees.yaml +++ b/generator/config/expression/radiansToDegrees.yaml @@ -22,3 +22,14 @@ tests: $radiansToDegrees: $angle_b angle_c_deg: $radiansToDegrees: $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/rand.yaml b/generator/config/expression/rand.yaml index a119a1596..9d84f4a9b 100644 --- a/generator/config/expression/rand.yaml +++ b/generator/config/expression/rand.yaml @@ -20,6 +20,17 @@ tests: $floor: $amount - $merge: into: donors + schema: + donors: + donorId: + types: + - bsonType: Number + amount: + types: + - bsonType: Number + frequency: + types: + - bsonType: Number - 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: @@ -34,3 +45,17 @@ tests: _id: 0 name: 1 registered: 1 + schema: + voters: + name: + types: + - bsonType: String + voterId: + types: + - bsonType: Number + district: + types: + - bsonType: Number + registered: + types: + - bsonType: Boolean diff --git a/generator/config/expression/range.yaml b/generator/config/expression/range.yaml index 911cb9596..536734e54 100644 --- a/generator/config/expression/range.yaml +++ b/generator/config/expression/range.yaml @@ -35,3 +35,14 @@ tests: - 0 - $distance - 25 + schema: + distances: + _id: + types: + - bsonType: Number + city: + types: + - bsonType: String + distance: + types: + - bsonType: Number diff --git a/generator/config/expression/reduce.yaml b/generator/config/expression/reduce.yaml index 32211a5ea..3a20500d4 100644 --- a/generator/config/expression/reduce.yaml +++ b/generator/config/expression/reduce.yaml @@ -45,6 +45,26 @@ tests: $multiply: - $$value - $$this + schema: + events: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + experimentId: + types: + - bsonType: String + description: + types: + - bsonType: String + eventNum: + types: + - bsonType: Number + probability: + types: + - bsonType: Number - name: Discounted Merchandise link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#discounted-merchandise pipeline: @@ -59,6 +79,31 @@ tests: - $subtract: - 1 - $$this + schema: + clothes: + _id: + types: + - bsonType: Number + productId: + types: + - bsonType: String + description: + types: + - bsonType: String + color: + types: + - bsonType: String + size: + types: + - bsonType: String + price: + types: + - bsonType: Number + discounts: + types: + - bsonType: Array + types: + - bsonType: Number - name: String Concatenation link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#string-concatenation pipeline: @@ -82,6 +127,19 @@ tests: then: ' ' else: ', ' - $$this + schema: + people: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + hobbies: + types: + - bsonType: Array + types: + - bsonType: String - name: Array Concatenation link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#array-concatenation pipeline: @@ -94,6 +152,18 @@ tests: $concatArrays: - $$value - $$this + schema: + matrices: + _id: + types: + - bsonType: Number + arr: + types: + - bsonType: Array + types: + - bsonType: Array + types: + - bsonType: Number - name: Computing a Multiple Reductions link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/#computing-a-multiple-reductions pipeline: @@ -113,3 +183,23 @@ tests: - $slice: - $$this - 1 + schema: + events: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + experimentId: + types: + - bsonType: String + description: + types: + - bsonType: String + eventNum: + types: + - bsonType: Number + probability: + types: + - bsonType: Number diff --git a/generator/config/expression/regexFind.yaml b/generator/config/expression/regexFind.yaml index 346093494..b8440404a 100644 --- a/generator/config/expression/regexFind.yaml +++ b/generator/config/expression/regexFind.yaml @@ -32,6 +32,14 @@ tests: $regexFind: input: $description regex: !bson_regex line + schema: + products: + _id: + types: + - bsonType: Number + description: + types: + - bsonType: String - name: i Option link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/#i-option pipeline: @@ -54,3 +62,11 @@ tests: input: $description regex: !bson_regex line options: i + schema: + products: + _id: + types: + - bsonType: Number + description: + types: + - bsonType: String diff --git a/generator/config/expression/regexFindAll.yaml b/generator/config/expression/regexFindAll.yaml index 7e60baac2..fefd041c5 100644 --- a/generator/config/expression/regexFindAll.yaml +++ b/generator/config/expression/regexFindAll.yaml @@ -32,6 +32,14 @@ tests: $regexFindAll: input: $description regex: !bson_regex line + schema: + products: + _id: + types: + - bsonType: Number + description: + types: + - bsonType: String - name: i Option link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/#i-option pipeline: @@ -54,6 +62,14 @@ tests: input: $description regex: !bson_regex line options: i + schema: + products: + _id: + types: + - bsonType: Number + description: + types: + - bsonType: 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: @@ -66,6 +82,14 @@ tests: - i - $set: email: $email.match + schema: + feedback: + _id: + types: + - bsonType: Number + comment: + types: + - bsonType: String - 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: @@ -85,3 +109,11 @@ tests: $concatArrays: - $$value - $$this + schema: + feedback: + _id: + types: + - bsonType: Number + comment: + types: + - bsonType: String diff --git a/generator/config/expression/regexMatch.yaml b/generator/config/expression/regexMatch.yaml index 9d4016fbd..cb848634e 100644 --- a/generator/config/expression/regexMatch.yaml +++ b/generator/config/expression/regexMatch.yaml @@ -32,6 +32,14 @@ tests: $regexMatch: input: $description regex: !bson_regex line + schema: + products: + _id: + types: + - bsonType: Number + description: + types: + - bsonType: String - name: i Option link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/#i-option pipeline: @@ -54,6 +62,14 @@ tests: input: $description regex: !bson_regex line options: i + schema: + products: + _id: + types: + - bsonType: Number + description: + types: + - bsonType: String - 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: @@ -68,3 +84,11 @@ tests: - i then: Employee else: External + schema: + feedback: + _id: + types: + - bsonType: Number + comment: + types: + - bsonType: String diff --git a/generator/config/expression/replaceAll.yaml b/generator/config/expression/replaceAll.yaml index fceaadbc8..a21994617 100644 --- a/generator/config/expression/replaceAll.yaml +++ b/generator/config/expression/replaceAll.yaml @@ -37,3 +37,11 @@ tests: input: $item find: blue paint replacement: red paint + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String diff --git a/generator/config/expression/replaceOne.yaml b/generator/config/expression/replaceOne.yaml index 6c436c9c1..83daf14bc 100644 --- a/generator/config/expression/replaceOne.yaml +++ b/generator/config/expression/replaceOne.yaml @@ -36,3 +36,11 @@ tests: input: $item find: blue paint replacement: red paint + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String diff --git a/generator/config/expression/reverseArray.yaml b/generator/config/expression/reverseArray.yaml index 6e24ec388..55290f595 100644 --- a/generator/config/expression/reverseArray.yaml +++ b/generator/config/expression/reverseArray.yaml @@ -20,3 +20,16 @@ tests: name: 1 reverseFavorites: $reverseArray: $favorites + schema: + TestCollection: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + favorites: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/expression/round.yaml b/generator/config/expression/round.yaml index 516e04bdc..1063d5994 100644 --- a/generator/config/expression/round.yaml +++ b/generator/config/expression/round.yaml @@ -31,12 +31,11 @@ tests: $round: - $value - 1 - - name: Round Average Rating - pipeline: - - $project: - roundedAverageRating: - $avg: - - $round: - - $avg: - - $averageRating - - 2 + schema: + samples: + _id: + types: + - bsonType: Number + value: + types: + - bsonType: Number diff --git a/generator/config/expression/rtrim.yaml b/generator/config/expression/rtrim.yaml index 3df822042..7985a1827 100644 --- a/generator/config/expression/rtrim.yaml +++ b/generator/config/expression/rtrim.yaml @@ -29,3 +29,18 @@ tests: description: $rtrim: input: $description + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + quarter: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' diff --git a/generator/config/expression/second.yaml b/generator/config/expression/second.yaml index 11622edca..f52d8d17b 100644 --- a/generator/config/expression/second.yaml +++ b/generator/config/expression/second.yaml @@ -28,3 +28,20 @@ tests: seconds: $second: 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/setDifference.yaml b/generator/config/expression/setDifference.yaml index e7fc6acea..415fdb7c0 100644 --- a/generator/config/expression/setDifference.yaml +++ b/generator/config/expression/setDifference.yaml @@ -29,3 +29,21 @@ tests: - $flowerFieldB - $flowerFieldA _id: 0 + schema: + flowers: + _id: + types: + - bsonType: Number + flowerFieldA: + types: + - bsonType: Array + types: + - bsonType: String + flowerFieldB: + types: + - bsonType: Array + types: + - bsonType: String + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/expression/setEquals.yaml b/generator/config/expression/setEquals.yaml index de5a6be56..02d61250d 100644 --- a/generator/config/expression/setEquals.yaml +++ b/generator/config/expression/setEquals.yaml @@ -23,3 +23,18 @@ tests: $setEquals: - $cakes - $cupcakes + schema: + bakeryOrders: + _id: + types: + - bsonType: Number + cakes: + types: + - bsonType: Array + types: + - bsonType: String + cupcakes: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/expression/setField.yaml b/generator/config/expression/setField.yaml index 6f91c4504..fa1a71f33 100644 --- a/generator/config/expression/setField.yaml +++ b/generator/config/expression/setField.yaml @@ -35,6 +35,20 @@ tests: value: $price - $unset: - price + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + qty: + types: + - bsonType: Number - 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: @@ -46,6 +60,20 @@ tests: value: $price - $unset: - price + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + qty: + types: + - bsonType: Number - name: Update Fields that Contain Periods link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#update-fields-that-contain-periods--.- pipeline: @@ -56,6 +84,20 @@ tests: field: price.usd input: $$ROOT value: 49.99 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number + price.usd: + types: + - bsonType: Number - 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: @@ -67,6 +109,20 @@ tests: $literal: $price input: $$ROOT value: 49.99 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number + $price: + types: + - bsonType: Number - name: Remove Fields that Contain Periods link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/#remove-fields-that-contain-periods--.- pipeline: @@ -75,6 +131,20 @@ tests: field: price.usd input: $$ROOT value: $$REMOVE + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number + price.usd: + types: + - bsonType: Number - 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: @@ -84,3 +154,17 @@ tests: $literal: $price input: $$ROOT value: $$REMOVE + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + qty: + types: + - bsonType: Number diff --git a/generator/config/expression/setIntersection.yaml b/generator/config/expression/setIntersection.yaml index 5385b82ae..a41d68136 100644 --- a/generator/config/expression/setIntersection.yaml +++ b/generator/config/expression/setIntersection.yaml @@ -23,6 +23,24 @@ tests: - $flowerFieldA - $flowerFieldB _id: 0 + schema: + flowers: + _id: + types: + - bsonType: Number + flowerFieldA: + types: + - bsonType: Array + types: + - bsonType: String + flowerFieldB: + types: + - bsonType: Array + types: + - bsonType: String + - bsonType: Array + types: + - bsonType: String - 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: @@ -34,3 +52,27 @@ tests: - $allowedRoles - $$USER_ROLES.role - [] + schema: + budget: + _id: + types: + - bsonType: Int32 + allowedRoles: + types: + - bsonType: Array + types: + - bsonType: String + comment: + types: + - bsonType: String + yearlyBudget: + types: + - bsonType: Double + cloudBudget: + types: + - bsonType: Double + - bsonType: Undefined + salesEventsBudget: + types: + - bsonType: Double + - bsonType: Undefined diff --git a/generator/config/expression/setIsSubset.yaml b/generator/config/expression/setIsSubset.yaml index 5ecf9864e..74181df26 100644 --- a/generator/config/expression/setIsSubset.yaml +++ b/generator/config/expression/setIsSubset.yaml @@ -25,3 +25,21 @@ tests: - $flowerFieldA - $flowerFieldB _id: 0 + schema: + flowers: + _id: + types: + - bsonType: Number + flowerFieldA: + types: + - bsonType: Array + types: + - bsonType: String + flowerFieldB: + types: + - bsonType: Array + types: + - bsonType: String + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/expression/setUnion.yaml b/generator/config/expression/setUnion.yaml index baa7895ee..3ff906332 100644 --- a/generator/config/expression/setUnion.yaml +++ b/generator/config/expression/setUnion.yaml @@ -23,3 +23,21 @@ tests: - $flowerFieldA - $flowerFieldB _id: 0 + schema: + flowers: + _id: + types: + - bsonType: Number + flowerFieldA: + types: + - bsonType: Array + types: + - bsonType: String + flowerFieldB: + types: + - bsonType: Array + types: + - bsonType: String + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/expression/sin.yaml b/generator/config/expression/sin.yaml index 2e9a1e67c..3f1e8c6e1 100644 --- a/generator/config/expression/sin.yaml +++ b/generator/config/expression/sin.yaml @@ -24,3 +24,14 @@ tests: - $sin: $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/sinh.yaml b/generator/config/expression/sinh.yaml index 2250b4f24..99597385b 100644 --- a/generator/config/expression/sinh.yaml +++ b/generator/config/expression/sinh.yaml @@ -22,3 +22,11 @@ tests: sinh_output: $sinh: $degreesToRadians: $angle + schema: + trigonometry: + _id: + types: + - bsonType: ObjectId + angle: + types: + - bsonType: Decimal128 diff --git a/generator/config/expression/size.yaml b/generator/config/expression/size.yaml index 910715587..50d38c9ce 100644 --- a/generator/config/expression/size.yaml +++ b/generator/config/expression/size.yaml @@ -26,3 +26,20 @@ tests: then: $size: $colors else: NA + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + description: + types: + - bsonType: String + colors: + types: + - bsonType: Array + types: + - bsonType: String + - bsonType: String diff --git a/generator/config/expression/slice.yaml b/generator/config/expression/slice.yaml index a81534cf2..0abdb444d 100644 --- a/generator/config/expression/slice.yaml +++ b/generator/config/expression/slice.yaml @@ -37,3 +37,16 @@ tests: $slice: - $favorites - 3 + schema: + TestCollection: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + favorites: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/expression/sortArray.yaml b/generator/config/expression/sortArray.yaml index 21727c536..862be5191 100644 --- a/generator/config/expression/sortArray.yaml +++ b/generator/config/expression/sortArray.yaml @@ -32,6 +32,30 @@ tests: input: $team sortBy: name: 1 + schema: + engineers: + team: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + age: + types: + - bsonType: Number + address: + types: + - bsonType: Document + fields: + street: + types: + - bsonType: String + city: + types: + - bsonType: String - name: Sort on a Subfield link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-on-a-subfield pipeline: @@ -42,6 +66,30 @@ tests: input: $team sortBy: address.city: -1 + schema: + engineers: + team: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + age: + types: + - bsonType: Number + address: + types: + - bsonType: Document + fields: + street: + types: + - bsonType: String + city: + types: + - bsonType: String - name: Sort on Multiple Fields link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-on-multiple-fields pipeline: @@ -53,6 +101,30 @@ tests: sortBy: age: -1 name: 1 + schema: + engineers: + team: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + age: + types: + - bsonType: Number + address: + types: + - bsonType: Document + fields: + street: + types: + - bsonType: String + city: + types: + - bsonType: String - name: Sort an Array of Integers link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-an-array-of-integers pipeline: @@ -68,6 +140,30 @@ tests: - 12 - 5 sortBy: 1 + schema: + engineers: + team: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + age: + types: + - bsonType: Number + address: + types: + - bsonType: Document + fields: + street: + types: + - bsonType: String + city: + types: + - bsonType: String - name: Sort on Mixed Type Fields link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/#sort-on-mixed-type-fields pipeline: @@ -90,3 +186,27 @@ tests: - !bson_decimal128 '10.23' - a: On sale sortBy: 1 + schema: + engineers: + team: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + age: + types: + - bsonType: Number + address: + types: + - bsonType: Document + fields: + street: + types: + - bsonType: String + city: + types: + - bsonType: String diff --git a/generator/config/expression/split.yaml b/generator/config/expression/split.yaml index ce08ffe3d..e9c467e0b 100644 --- a/generator/config/expression/split.yaml +++ b/generator/config/expression/split.yaml @@ -38,3 +38,14 @@ tests: $sum: $qty - $sort: total_qty: -1 + schema: + deliveries: + _id: + types: + - bsonType: Number + city: + types: + - bsonType: String + qty: + types: + - bsonType: Number diff --git a/generator/config/expression/sqrt.yaml b/generator/config/expression/sqrt.yaml index 57f0929e9..860731699 100644 --- a/generator/config/expression/sqrt.yaml +++ b/generator/config/expression/sqrt.yaml @@ -30,3 +30,28 @@ tests: - $p2.x - $p1.x - 2 + schema: + TestCollection: + _id: + types: + - bsonType: Number + p1: + types: + - bsonType: Document + fields: + x: + types: + - bsonType: Number + y: + types: + - bsonType: Number + p2: + types: + - bsonType: Document + fields: + x: + types: + - bsonType: Number + y: + types: + - bsonType: Number diff --git a/generator/config/expression/stdDevPop.yaml b/generator/config/expression/stdDevPop.yaml index 45ec5804f..62154c684 100644 --- a/generator/config/expression/stdDevPop.yaml +++ b/generator/config/expression/stdDevPop.yaml @@ -21,3 +21,23 @@ tests: stdDev: $stdDevPop: - $scores.score + schema: + quizzes: + _id: + types: + - bsonType: Number + scores: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + score: + types: + - bsonType: Number + quiz: + types: + - bsonType: Number diff --git a/generator/config/expression/strLenBytes.yaml b/generator/config/expression/strLenBytes.yaml index a554a1797..55012f35d 100644 --- a/generator/config/expression/strLenBytes.yaml +++ b/generator/config/expression/strLenBytes.yaml @@ -18,3 +18,11 @@ tests: name: 1 length: $strLenBytes: $name + schema: + food: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String diff --git a/generator/config/expression/strLenCP.yaml b/generator/config/expression/strLenCP.yaml index 0f11ebff7..e0586ee38 100644 --- a/generator/config/expression/strLenCP.yaml +++ b/generator/config/expression/strLenCP.yaml @@ -18,3 +18,11 @@ tests: name: 1 length: $strLenCP: $name + schema: + food: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String diff --git a/generator/config/expression/strcasecmp.yaml b/generator/config/expression/strcasecmp.yaml index fc2ef6980..78cf85c33 100644 --- a/generator/config/expression/strcasecmp.yaml +++ b/generator/config/expression/strcasecmp.yaml @@ -23,3 +23,18 @@ tests: $strcasecmp: - $quarter - 13q4 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + quarter: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' diff --git a/generator/config/expression/substr.yaml b/generator/config/expression/substr.yaml index a3d9c027a..457b679c0 100644 --- a/generator/config/expression/substr.yaml +++ b/generator/config/expression/substr.yaml @@ -36,3 +36,18 @@ tests: - $quarter - 2 - -1 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + quarter: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' diff --git a/generator/config/expression/substrBytes.yaml b/generator/config/expression/substrBytes.yaml index 4d9465f26..b3abec24d 100644 --- a/generator/config/expression/substrBytes.yaml +++ b/generator/config/expression/substrBytes.yaml @@ -38,6 +38,21 @@ tests: - $subtract: - $strLenBytes: $quarter - 2 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + quarter: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' - 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: @@ -48,3 +63,11 @@ tests: - $name - 0 - 3 + schema: + food: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String diff --git a/generator/config/expression/substrCP.yaml b/generator/config/expression/substrCP.yaml index 46369dd32..d0a278607 100644 --- a/generator/config/expression/substrCP.yaml +++ b/generator/config/expression/substrCP.yaml @@ -38,6 +38,21 @@ tests: - $subtract: - $strLenCP: $quarter - 2 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + quarter: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' - 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: @@ -48,3 +63,11 @@ tests: - $name - 0 - 3 + schema: + food: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String diff --git a/generator/config/expression/subtract.yaml b/generator/config/expression/subtract.yaml index eeb7ba4b9..e5f0770a0 100644 --- a/generator/config/expression/subtract.yaml +++ b/generator/config/expression/subtract.yaml @@ -31,6 +31,26 @@ tests: - $price - $fee - $discount + schema: + sales: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + fee: + types: + - bsonType: Number + discount: + types: + - bsonType: Number + date: + types: + - bsonType: Date - name: Subtract Two Dates link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#subtract-two-dates pipeline: @@ -40,6 +60,26 @@ tests: $subtract: - $$NOW - $date + schema: + sales: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + fee: + types: + - bsonType: Number + discount: + types: + - bsonType: Number + date: + types: + - bsonType: Date - name: Subtract Milliseconds from a Date link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/#subtract-milliseconds-from-a-date pipeline: @@ -49,3 +89,23 @@ tests: $subtract: - $date - 300000 + schema: + sales: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + fee: + types: + - bsonType: Number + discount: + types: + - bsonType: Number + date: + types: + - bsonType: Date diff --git a/generator/config/expression/sum.yaml b/generator/config/expression/sum.yaml index 626905350..bb4ed3a48 100644 --- a/generator/config/expression/sum.yaml +++ b/generator/config/expression/sum.yaml @@ -28,3 +28,24 @@ tests: $sum: - $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/switch.yaml b/generator/config/expression/switch.yaml index 33e39ee18..f68a82775 100644 --- a/generator/config/expression/switch.yaml +++ b/generator/config/expression/switch.yaml @@ -55,3 +55,16 @@ tests: - 80 then: Needs improvement. default: No scores found. + schema: + TestCollection: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + scores: + types: + - bsonType: Array + types: + - bsonType: Number diff --git a/generator/config/expression/tan.yaml b/generator/config/expression/tan.yaml index ed9977486..859c4a5d0 100644 --- a/generator/config/expression/tan.yaml +++ b/generator/config/expression/tan.yaml @@ -24,3 +24,14 @@ tests: - $tan: $degreesToRadians: $angle_a - $side_a + schema: + TestCollection: + _id: + types: + - bsonType: ObjectId + angle_a: + types: + - bsonType: Decimal128 + side_a: + types: + - bsonType: Decimal128 diff --git a/generator/config/expression/tanh.yaml b/generator/config/expression/tanh.yaml index 71d79ab07..67daa9d1a 100644 --- a/generator/config/expression/tanh.yaml +++ b/generator/config/expression/tanh.yaml @@ -22,3 +22,11 @@ tests: tanh_output: $tanh: $degreesToRadians: $angle + schema: + trigonometry: + _id: + types: + - bsonType: ObjectId + angle: + types: + - bsonType: Decimal128 diff --git a/generator/config/expression/toBool.yaml b/generator/config/expression/toBool.yaml index e1756ca9d..748aa5411 100644 --- a/generator/config/expression/toBool.yaml +++ b/generator/config/expression/toBool.yaml @@ -33,3 +33,19 @@ tests: $toBool: $shipped - $match: convertedShippedFlag: false + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number + shipped: + types: + - bsonType: String + - bsonType: Number + - bsonType: Boolean diff --git a/generator/config/expression/toDate.yaml b/generator/config/expression/toDate.yaml index 626cdd34a..ebf4218dd 100644 --- a/generator/config/expression/toDate.yaml +++ b/generator/config/expression/toDate.yaml @@ -20,3 +20,21 @@ tests: $toDate: $order_date - $sort: convertedDate: 1 + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number + price: + types: + - bsonType: Number + order_date: + types: + - bsonType: Date + - bsonType: String diff --git a/generator/config/expression/toDecimal.yaml b/generator/config/expression/toDecimal.yaml index 6735f3516..2af8c6efa 100644 --- a/generator/config/expression/toDecimal.yaml +++ b/generator/config/expression/toDecimal.yaml @@ -18,3 +18,19 @@ tests: - $addFields: convertedPrice: $toDecimal: $price + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number + price: + types: + - bsonType: Number + - bsonType: Decimal128 + - bsonType: String diff --git a/generator/config/expression/toDouble.yaml b/generator/config/expression/toDouble.yaml index 93fc569cb..f7a5eec60 100644 --- a/generator/config/expression/toDouble.yaml +++ b/generator/config/expression/toDouble.yaml @@ -22,3 +22,14 @@ tests: - $temp - 0 - 4 + schema: + weather: + _id: + types: + - bsonType: Number + date: + types: + - bsonType: Date + temp: + types: + - bsonType: String diff --git a/generator/config/expression/toHashedIndexKey.yaml b/generator/config/expression/toHashedIndexKey.yaml index a6b556662..260a2ea6e 100644 --- a/generator/config/expression/toHashedIndexKey.yaml +++ b/generator/config/expression/toHashedIndexKey.yaml @@ -21,3 +21,8 @@ tests: - $addFields: hashedVal: $toHashedIndexKey: $val + schema: + TestCollection: + val: + types: + - bsonType: String diff --git a/generator/config/expression/toInt.yaml b/generator/config/expression/toInt.yaml index d8b1cf113..5d2a79fc0 100644 --- a/generator/config/expression/toInt.yaml +++ b/generator/config/expression/toInt.yaml @@ -18,3 +18,19 @@ tests: - $addFields: convertedQty: $toInt: $qty + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: String + price: + types: + - bsonType: Number + - bsonType: Decimal128 + - bsonType: String diff --git a/generator/config/expression/toLong.yaml b/generator/config/expression/toLong.yaml index c78cdebf1..cd278dd98 100644 --- a/generator/config/expression/toLong.yaml +++ b/generator/config/expression/toLong.yaml @@ -20,3 +20,16 @@ tests: $toLong: $qty - $sort: convertedQty: -1 + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: String + - bsonType: Int32 + - bsonType: Long diff --git a/generator/config/expression/toLower.yaml b/generator/config/expression/toLower.yaml index 349073e8e..7dc0861f5 100644 --- a/generator/config/expression/toLower.yaml +++ b/generator/config/expression/toLower.yaml @@ -19,3 +19,18 @@ tests: $toLower: $item description: $toLower: $description + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + quarter: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' diff --git a/generator/config/expression/toObjectId.yaml b/generator/config/expression/toObjectId.yaml index 54f696346..5a1c75ed7 100644 --- a/generator/config/expression/toObjectId.yaml +++ b/generator/config/expression/toObjectId.yaml @@ -20,3 +20,15 @@ tests: $toObjectId: $_id - $sort: convertedId: -1 + schema: + orders: + _id: + types: + - bsonType: String + - bsonType: ObjectId + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number diff --git a/generator/config/expression/toString.yaml b/generator/config/expression/toString.yaml index f58d27789..44c139922 100644 --- a/generator/config/expression/toString.yaml +++ b/generator/config/expression/toString.yaml @@ -20,3 +20,18 @@ tests: $toString: $zipcode - $sort: convertedZipCode: 1 + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number + zipcode: + types: + - bsonType: Number + - bsonType: String diff --git a/generator/config/expression/toUpper.yaml b/generator/config/expression/toUpper.yaml index a36cc1263..a69c1ab35 100644 --- a/generator/config/expression/toUpper.yaml +++ b/generator/config/expression/toUpper.yaml @@ -19,3 +19,18 @@ tests: $toUpper: $item description: $toUpper: $description + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + quarter: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' diff --git a/generator/config/expression/trim.yaml b/generator/config/expression/trim.yaml index 929d5233c..4c5d4c699 100644 --- a/generator/config/expression/trim.yaml +++ b/generator/config/expression/trim.yaml @@ -30,3 +30,18 @@ tests: description: $trim: input: $description + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + quarter: + types: + - bsonType: String + description: + types: + - bsonType: String + - bsonType: 'Null' diff --git a/generator/config/expression/trunc.yaml b/generator/config/expression/trunc.yaml index bb458d4f5..1db19b2f6 100644 --- a/generator/config/expression/trunc.yaml +++ b/generator/config/expression/trunc.yaml @@ -28,3 +28,11 @@ tests: $trunc: - $value - 1 + schema: + samples: + _id: + types: + - bsonType: Number + value: + types: + - bsonType: Number diff --git a/generator/config/expression/tsIncrement.yaml b/generator/config/expression/tsIncrement.yaml index 28a9dae2f..e00416892 100644 --- a/generator/config/expression/tsIncrement.yaml +++ b/generator/config/expression/tsIncrement.yaml @@ -20,6 +20,17 @@ tests: saleTimestamp: 1 saleIncrement: $tsIncrement: $saleTimestamp + schema: + stockSales: + _id: + types: + - bsonType: Number + symbol: + types: + - bsonType: String + saleTimestamp: + types: + - bsonType: Timestamp - 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: @@ -30,3 +41,14 @@ tests: - $tsIncrement: $clusterTime - 2 - 0 + schema: + stockSales: + _id: + types: + - bsonType: Number + symbol: + types: + - bsonType: String + saleTimestamp: + types: + - bsonType: Timestamp diff --git a/generator/config/expression/tsSecond.yaml b/generator/config/expression/tsSecond.yaml index 436858368..4f40426c3 100644 --- a/generator/config/expression/tsSecond.yaml +++ b/generator/config/expression/tsSecond.yaml @@ -20,9 +20,31 @@ tests: saleTimestamp: 1 saleSeconds: $tsSecond: $saleTimestamp + schema: + stockSales: + _id: + types: + - bsonType: Number + symbol: + types: + - bsonType: String + saleTimestamp: + types: + - bsonType: Timestamp - 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 + schema: + stockSales: + _id: + types: + - bsonType: Number + symbol: + types: + - bsonType: String + saleTimestamp: + types: + - bsonType: Timestamp diff --git a/generator/config/expression/type.yaml b/generator/config/expression/type.yaml index 2c210c47a..3f9eb7fa4 100644 --- a/generator/config/expression/type.yaml +++ b/generator/config/expression/type.yaml @@ -17,3 +17,27 @@ tests: - $project: a: $type: $a + schema: + TestCollection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Array + types: + - bsonType: Number + - bsonType: Document + fields: + a: + types: + - bsonType: String + b: + types: + - bsonType: String + c: + types: + - bsonType: String + - bsonType: String + - bsonType: Long diff --git a/generator/config/expression/unsetField.yaml b/generator/config/expression/unsetField.yaml index 4dc863852..0dd1b0eba 100644 --- a/generator/config/expression/unsetField.yaml +++ b/generator/config/expression/unsetField.yaml @@ -26,6 +26,20 @@ tests: $unsetField: field: price.usd input: $$ROOT + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number + price.usd: + types: + - bsonType: Number - 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: @@ -34,6 +48,20 @@ tests: field: $literal: $price input: $$ROOT + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number + $price: + types: + - bsonType: Number - name: Remove A Subfield link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/#remove-a-subfield pipeline: @@ -47,3 +75,24 @@ tests: input: $getField: field: price + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number + price: + types: + - bsonType: Document + fields: + usd: + types: + - bsonType: Number + euro: + types: + - bsonType: Number diff --git a/generator/config/expression/week.yaml b/generator/config/expression/week.yaml index 09324d4cc..978513add 100644 --- a/generator/config/expression/week.yaml +++ b/generator/config/expression/week.yaml @@ -28,3 +28,20 @@ tests: week: $week: 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/year.yaml b/generator/config/expression/year.yaml index c6d664ea8..6ac43e610 100644 --- a/generator/config/expression/year.yaml +++ b/generator/config/expression/year.yaml @@ -28,3 +28,20 @@ tests: year: $year: 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/zip.yaml b/generator/config/expression/zip.yaml index 80f677bfe..48c7fe942 100644 --- a/generator/config/expression/zip.yaml +++ b/generator/config/expression/zip.yaml @@ -47,6 +47,15 @@ tests: - $arrayElemAt: - $matrix - 2 + schema: + matrices: + matrix: + types: + - bsonType: Array + types: + - bsonType: Array + types: + - bsonType: Number - name: Filtering and Preserving Indexes link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/#filtering-and-preserving-indexes pipeline: @@ -73,3 +82,20 @@ tests: $gte: - $$page.reviews - 1 + schema: + pages: + category: + types: + - bsonType: String + pages: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + title: + types: + - bsonType: String + reviews: + types: + - bsonType: Number From fd06dd661102bd44e346e267bba595aaabe4e9c6 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 22 May 2025 17:40:24 +0200 Subject: [PATCH 08/16] add test schemas for query --- generator/config/query/all.yaml | 56 ++++++++++++ generator/config/query/and.yaml | 16 ++++ generator/config/query/bitsAllClear.yaml | 36 ++++++++ generator/config/query/bitsAllSet.yaml | 36 ++++++++ generator/config/query/bitsAnyClear.yaml | 36 ++++++++ generator/config/query/bitsAnySet.yaml | 36 ++++++++ generator/config/query/comment.yaml | 27 ------ generator/config/query/elemMatch.yaml | 61 +++++++++---- generator/config/query/eq.yaml | 104 ++++++++++++++++++++++ generator/config/query/exists.yaml | 25 ++++-- generator/config/query/expr.yaml | 30 ++++++- generator/config/query/geoIntersects.yaml | 36 ++++++++ generator/config/query/geoWithin.yaml | 36 ++++++++ generator/config/query/gt.yaml | 18 ++++ generator/config/query/gte.yaml | 18 ++++ generator/config/query/in.yaml | 26 ++++++ generator/config/query/jsonSchema.yaml | 21 +++++ generator/config/query/lt.yaml | 18 ++++ generator/config/query/lte.yaml | 18 ++++ generator/config/query/mod.yaml | 22 +++++ generator/config/query/ne.yaml | 20 ++++- generator/config/query/near.yaml | 14 +++ generator/config/query/nearSphere.yaml | 14 +++ generator/config/query/nin.yaml | 26 ++++++ generator/config/query/nor.yaml | 33 +++++++ generator/config/query/not.yaml | 24 ++++- generator/config/query/or.yaml | 16 ++++ generator/config/query/rand.yaml | 14 +++ generator/config/query/regex.yaml | 22 +++++ generator/config/query/sampleRate.yaml | 5 ++ generator/config/query/size.yaml | 11 +++ generator/config/query/text.yaml | 104 +++++++++++++++++++--- generator/config/query/type.yaml | 68 +++++++++++++- generator/config/query/where.yaml | 14 +++ generator/config/schema.json | 1 + 35 files changed, 997 insertions(+), 65 deletions(-) delete mode 100644 generator/config/query/comment.yaml diff --git a/generator/config/query/all.yaml b/generator/config/query/all.yaml index 8dbea6384..a17c092e7 100644 --- a/generator/config/query/all.yaml +++ b/generator/config/query/all.yaml @@ -21,6 +21,34 @@ tests: - appliance - school - book + schema: + inventory: + _id: + types: + - bsonType: ObjectId + code: + types: + - bsonType: String + tags: + types: + - bsonType: Array + types: + - bsonType: String + qty: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + size: + types: + - bsonType: String + num: + types: + - bsonType: Number + color: + types: + - bsonType: String - name: Use $all with $elemMatch link: https://www.mongodb.com/docs/manual/reference/operator/query/all/#use--all-with--elemmatch pipeline: @@ -34,3 +62,31 @@ tests: - $elemMatch: num: 100 color: green + schema: + inventory: + _id: + types: + - bsonType: ObjectId + code: + types: + - bsonType: String + tags: + types: + - bsonType: Array + types: + - bsonType: String + qty: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + size: + types: + - bsonType: String + num: + types: + - bsonType: Number + color: + types: + - bsonType: String diff --git a/generator/config/query/and.yaml b/generator/config/query/and.yaml index 22cf3a143..8db9f894b 100644 --- a/generator/config/query/and.yaml +++ b/generator/config/query/and.yaml @@ -22,6 +22,11 @@ tests: $ne: 1.99 - price: $exists: true + schema: + inventory: + price: + types: + - bsonType: Double - 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: @@ -36,3 +41,14 @@ tests: - sale: true - price: $lt: 5 + schema: + inventory: + price: + types: + - bsonType: Double + qty: + types: + - bsonType: Int32 + sale: + types: + - bsonType: Boolean diff --git a/generator/config/query/bitsAllClear.yaml b/generator/config/query/bitsAllClear.yaml index 08151f6d3..160dd6410 100644 --- a/generator/config/query/bitsAllClear.yaml +++ b/generator/config/query/bitsAllClear.yaml @@ -21,15 +21,51 @@ tests: $bitsAllClear: - 1 - 5 + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String - name: Integer Bitmask link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#integer-bitmask pipeline: - $match: a: $bitsAllClear: 35 + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String - name: BinData Bitmask link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/#bindata-bitmask pipeline: - $match: a: $bitsAllClear: !bson_binary IA== + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String diff --git a/generator/config/query/bitsAllSet.yaml b/generator/config/query/bitsAllSet.yaml index 8ed3d9fea..ad9f35a77 100644 --- a/generator/config/query/bitsAllSet.yaml +++ b/generator/config/query/bitsAllSet.yaml @@ -21,15 +21,51 @@ tests: $bitsAllSet: - 1 - 5 + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String - name: Integer Bitmask link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#integer-bitmask pipeline: - $match: a: $bitsAllSet: 50 + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String - name: BinData Bitmask link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/#bindata-bitmask pipeline: - $match: a: $bitsAllSet: !bson_binary MA== + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String diff --git a/generator/config/query/bitsAnyClear.yaml b/generator/config/query/bitsAnyClear.yaml index 4f649b8e2..c4f4a2114 100644 --- a/generator/config/query/bitsAnyClear.yaml +++ b/generator/config/query/bitsAnyClear.yaml @@ -21,15 +21,51 @@ tests: $bitsAnyClear: - 1 - 5 + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String - name: Integer Bitmask link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#integer-bitmask pipeline: - $match: a: $bitsAnyClear: 35 + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String - name: BinData Bitmask link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/#bindata-bitmask pipeline: - $match: a: $bitsAnyClear: !bson_binary MA== + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String diff --git a/generator/config/query/bitsAnySet.yaml b/generator/config/query/bitsAnySet.yaml index 10bef034d..df82d9b39 100644 --- a/generator/config/query/bitsAnySet.yaml +++ b/generator/config/query/bitsAnySet.yaml @@ -21,15 +21,51 @@ tests: $bitsAnySet: - 1 - 5 + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String - name: Integer Bitmask link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#integer-bitmask pipeline: - $match: a: $bitsAnySet: 35 + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String - name: BinData Bitmask link: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/#bindata-bitmask pipeline: - $match: a: $bitsAnySet: !bson_binary MA== + schema: + collection: + _id: + types: + - bsonType: Number + a: + types: + - bsonType: Number + - bsonType: Binary + binaryValueofA: + types: + - bsonType: String diff --git a/generator/config/query/comment.yaml b/generator/config/query/comment.yaml deleted file mode 100644 index 54f04bed8..000000000 --- a/generator/config/query/comment.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# $schema: ../schema.json -name: $comment -link: https://www.mongodb.com/docs/manual/reference/operator/query/comment/ -type: - - query -encode: single -description: | - Adds a comment to a query predicate. -arguments: - - name: comment - type: - - 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 - pipeline: - - $match: - x: - $gt: 0 - $comment: Don't allow negative inputs. - - $group: - _id: - $mod: - - $x - - 2 - total: - $sum: $x diff --git a/generator/config/query/elemMatch.yaml b/generator/config/query/elemMatch.yaml index f2ecbbe8e..b0c9aa0d7 100644 --- a/generator/config/query/elemMatch.yaml +++ b/generator/config/query/elemMatch.yaml @@ -20,6 +20,16 @@ tests: $elemMatch: $gte: 80 $lt: 85 + schema: + TestCollection: + _id: + types: + - bsonType: Number + results: + types: + - bsonType: Array + types: + - bsonType: Number - name: Array of Embedded Documents link: https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/#array-of-embedded-documents pipeline: @@ -29,6 +39,31 @@ tests: product: xyz score: $gte: 8 + schema: + survey: + _id: + types: + - bsonType: Number + results: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + product: + types: + - bsonType: String + score: + types: + - bsonType: Number + - bsonType: Document + fields: + product: + types: + - bsonType: String + score: + types: + - bsonType: Number - name: Single Query Condition link: https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/#single-query-condition pipeline: @@ -37,19 +72,13 @@ tests: $elemMatch: product: $ne: xyz - - name: Using $or with $elemMatch - pipeline: - - $match: - game: - $elemMatch: - $or: - - score: - $gt: 10 - - score: - $lt: 5 - - name: Single field operator - pipeline: - - $match: - results: - $elemMatch: - $gt: 10 + schema: + TestCollection: + _id: + types: + - bsonType: Number + results: + types: + - bsonType: Array + types: + - bsonType: Number diff --git a/generator/config/query/eq.yaml b/generator/config/query/eq.yaml index fa6060e93..746440243 100644 --- a/generator/config/query/eq.yaml +++ b/generator/config/query/eq.yaml @@ -17,12 +17,64 @@ tests: - $match: qty: $eq: 20 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + code: + types: + - bsonType: String + qty: + types: + - bsonType: Number + tags: + types: + - bsonType: Array + types: + - bsonType: String + - bsonType: Array + types: + - bsonType: String - 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 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + code: + types: + - bsonType: String + qty: + types: + - bsonType: Number + tags: + types: + - bsonType: Array + types: + - bsonType: String + - bsonType: Array + types: + - bsonType: String - name: Equals an Array Value link: https://www.mongodb.com/docs/manual/reference/operator/query/eq/#equals-an-array-value pipeline: @@ -31,6 +83,32 @@ tests: $eq: - A - B + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + code: + types: + - bsonType: String + qty: + types: + - bsonType: Number + tags: + types: + - bsonType: Array + types: + - bsonType: String + - bsonType: Array + types: + - bsonType: String - name: Regex Match Behaviour link: https://www.mongodb.com/docs/manual/reference/operator/query/eq/#regex-match-behaviour pipeline: @@ -44,3 +122,29 @@ tests: - $match: company: $eq: !bson_regex ^MongoDB + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + code: + types: + - bsonType: String + qty: + types: + - bsonType: Number + tags: + types: + - bsonType: Array + types: + - bsonType: String + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/query/exists.yaml b/generator/config/query/exists.yaml index a05958a3f..52febc113 100644 --- a/generator/config/query/exists.yaml +++ b/generator/config/query/exists.yaml @@ -21,14 +21,29 @@ tests: $nin: - 5 - 15 + schema: + inventory: + qty: + types: + - bsonType: Int32 + - bsonType: Undefined - name: Null Values link: https://www.mongodb.com/docs/manual/reference/operator/query/exists/#null-values pipeline: - $match: qty: $exists: true - - name: Missing Field - pipeline: - - $match: - qty: - $exists: false + schema: + spices: + saffron: + types: + - bsonType: Number + - bsonType: 'Null' + cinnamon: + types: + - bsonType: Number + - bsonType: 'Null' + mustard: + types: + - bsonType: Number + - bsonType: 'Null' diff --git a/generator/config/query/expr.yaml b/generator/config/query/expr.yaml index 57e68bc85..7cf0199e7 100644 --- a/generator/config/query/expr.yaml +++ b/generator/config/query/expr.yaml @@ -19,8 +19,22 @@ tests: $gt: - $spent - $budget + schema: + monthlyBudget: + _id: + types: + - bsonType: Number + category: + types: + - bsonType: String + budget: + types: + - bsonType: Number + spent: + types: + - bsonType: Number - name: Using $expr With Conditional Statements - link: https://www.mongodb.com/docs/manual/reference/operator/query/expr/#using--expr-with-conditional-statements + link: https://www.mongodb.com/docs/manual/reference/operator/query/expr/#use--expr-with-conditional-statements pipeline: - $match: $expr: @@ -39,3 +53,17 @@ tests: - $price - 0.75 - 5 + schema: + monthlyBudget: + _id: + types: + - bsonType: Number + category: + types: + - bsonType: String + budget: + types: + - bsonType: Number + spent: + types: + - bsonType: Number diff --git a/generator/config/query/geoIntersects.yaml b/generator/config/query/geoIntersects.yaml index 075bc280d..c46c8dac6 100644 --- a/generator/config/query/geoIntersects.yaml +++ b/generator/config/query/geoIntersects.yaml @@ -29,6 +29,24 @@ tests: - 1 - - 0 - 0 + schema: + places: + loc: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Array + types: + - bsonType: Array + types: + - bsonType: Double - name: Intersects a Big Polygon link: https://www.mongodb.com/docs/manual/reference/operator/query/geoIntersects/#intersects-a--big--polygon pipeline: @@ -54,3 +72,21 @@ tests: type: name properties: name: urn:x-mongodb:crs:strictwinding:EPSG:4326 + schema: + places: + loc: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Array + types: + - bsonType: Array + types: + - bsonType: Double diff --git a/generator/config/query/geoWithin.yaml b/generator/config/query/geoWithin.yaml index d5216d1b0..7b439c94c 100644 --- a/generator/config/query/geoWithin.yaml +++ b/generator/config/query/geoWithin.yaml @@ -29,6 +29,24 @@ tests: - 1 - - 0 - 0 + schema: + places: + loc: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Array + types: + - bsonType: Array + types: + - bsonType: Double - name: Within a Big Polygon link: https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/#within-a--big--polygon pipeline: @@ -54,3 +72,21 @@ tests: type: name properties: name: urn:x-mongodb:crs:strictwinding:EPSG:4326 + schema: + places: + loc: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Array + types: + - bsonType: Array + types: + - bsonType: Double diff --git a/generator/config/query/gt.yaml b/generator/config/query/gt.yaml index 5678ac953..afc82ad76 100644 --- a/generator/config/query/gt.yaml +++ b/generator/config/query/gt.yaml @@ -17,3 +17,21 @@ tests: - $match: qty: $gt: 20 + schema: + inventory: + item: + types: + - bsonType: String + quantity: + types: + - bsonType: Number + carrier: + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + fee: + types: + - bsonType: Number diff --git a/generator/config/query/gte.yaml b/generator/config/query/gte.yaml index e12dc1fce..c4ab311e8 100644 --- a/generator/config/query/gte.yaml +++ b/generator/config/query/gte.yaml @@ -17,3 +17,21 @@ tests: - $match: qty: $gte: 20 + schema: + inventory: + item: + types: + - bsonType: String + quantity: + types: + - bsonType: Number + carrier: + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + fee: + types: + - bsonType: Number diff --git a/generator/config/query/in.yaml b/generator/config/query/in.yaml index 0922f839b..59539de62 100644 --- a/generator/config/query/in.yaml +++ b/generator/config/query/in.yaml @@ -19,6 +19,19 @@ tests: $in: - home - school + schema: + inventory: + item: + types: + - bsonType: String + quantity: + types: + - bsonType: Number + tags: + types: + - bsonType: Array + types: + - bsonType: String - 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: @@ -27,3 +40,16 @@ tests: $in: - !bson_regex ^be - !bson_regex ^st + schema: + inventory: + item: + types: + - bsonType: String + quantity: + types: + - bsonType: Number + tags: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/query/jsonSchema.yaml b/generator/config/query/jsonSchema.yaml index a947cc77c..645381318 100644 --- a/generator/config/query/jsonSchema.yaml +++ b/generator/config/query/jsonSchema.yaml @@ -34,3 +34,24 @@ tests: bsonType: string zipcode: bsonType: string + schema: + TestCollection: + name: + types: + - bsonType: String + major: + types: + - bsonType: String + gpa: + types: + - bsonType: Double + address: + types: + - bsonType: Document + fields: + street: + types: + - bsonType: String + zipcode: + types: + - bsonType: String diff --git a/generator/config/query/lt.yaml b/generator/config/query/lt.yaml index 635aeff9b..9db08a5ff 100644 --- a/generator/config/query/lt.yaml +++ b/generator/config/query/lt.yaml @@ -17,3 +17,21 @@ tests: - $match: qty: $lt: 20 + schema: + inventory: + item: + types: + - bsonType: String + quantity: + types: + - bsonType: Number + carrier: + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + fee: + types: + - bsonType: Number diff --git a/generator/config/query/lte.yaml b/generator/config/query/lte.yaml index bbf74d293..a124d76d6 100644 --- a/generator/config/query/lte.yaml +++ b/generator/config/query/lte.yaml @@ -17,3 +17,21 @@ tests: - $match: qty: $lte: 20 + schema: + inventory: + item: + types: + - bsonType: String + quantity: + types: + - bsonType: Number + carrier: + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + fee: + types: + - bsonType: Number diff --git a/generator/config/query/mod.yaml b/generator/config/query/mod.yaml index e7451623a..9199c11e5 100644 --- a/generator/config/query/mod.yaml +++ b/generator/config/query/mod.yaml @@ -22,6 +22,17 @@ tests: $mod: - 4 - 0 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number - name: Floating Point Arguments link: https://www.mongodb.com/docs/manual/reference/operator/query/mod/#floating-point-arguments pipeline: @@ -40,3 +51,14 @@ tests: $mod: - 4.99 - 0 + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + qty: + types: + - bsonType: Number diff --git a/generator/config/query/ne.yaml b/generator/config/query/ne.yaml index 93f78d24c..f997c8931 100644 --- a/generator/config/query/ne.yaml +++ b/generator/config/query/ne.yaml @@ -12,8 +12,26 @@ arguments: - any tests: - name: Match Document Fields - link: https://www.mongodb.com/docs/manual/reference/operator/query/ne/#match-document-fields + link: https://www.mongodb.com/docs/manual/reference/operator/query/ne/#match-document-fields-that-are-not-equal pipeline: - $match: quantity: $ne: 20 + schema: + inventory: + item: + types: + - bsonType: String + quantity: + types: + - bsonType: Number + carrier: + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + fee: + types: + - bsonType: Number diff --git a/generator/config/query/near.yaml b/generator/config/query/near.yaml index 386d0386b..5749e12ea 100644 --- a/generator/config/query/near.yaml +++ b/generator/config/query/near.yaml @@ -37,3 +37,17 @@ tests: - 40.78 $minDistance: 1000 $maxDistance: 5000 + schema: + places: + location: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Double diff --git a/generator/config/query/nearSphere.yaml b/generator/config/query/nearSphere.yaml index 2868cc9e9..82607bad6 100644 --- a/generator/config/query/nearSphere.yaml +++ b/generator/config/query/nearSphere.yaml @@ -37,3 +37,17 @@ tests: - 40.78 $minDistance: 1000 $maxDistance: 5000 + schema: + places: + location: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Double diff --git a/generator/config/query/nin.yaml b/generator/config/query/nin.yaml index 8de46630c..5eb818699 100644 --- a/generator/config/query/nin.yaml +++ b/generator/config/query/nin.yaml @@ -19,6 +19,19 @@ tests: $nin: - 5 - 15 + schema: + inventory: + item: + types: + - bsonType: String + quantity: + types: + - bsonType: Number + tags: + types: + - bsonType: Array + types: + - bsonType: String - 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: @@ -26,3 +39,16 @@ tests: tags: $nin: - school + schema: + inventory: + item: + types: + - bsonType: String + quantity: + types: + - bsonType: Number + tags: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/query/nor.yaml b/generator/config/query/nor.yaml index 739ade2ca..e4fa857ca 100644 --- a/generator/config/query/nor.yaml +++ b/generator/config/query/nor.yaml @@ -20,6 +20,17 @@ tests: $nor: - price: 1.99 - sale: true + schema: + inventory: + price: + types: + - bsonType: Double + qty: + types: + - bsonType: Int32 + sale: + types: + - bsonType: Boolean - name: Additional Comparisons link: https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and-additional-comparisons pipeline: @@ -29,6 +40,17 @@ tests: - qty: $lt: 20 - sale: true + schema: + inventory: + price: + types: + - bsonType: Double + qty: + types: + - bsonType: Int32 + sale: + types: + - bsonType: Boolean - name: $nor and $exists link: https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and--exists pipeline: @@ -40,3 +62,14 @@ tests: - sale: true - sale: $exists: false + schema: + inventory: + price: + types: + - bsonType: Double + qty: + types: + - bsonType: Int32 + sale: + types: + - bsonType: Boolean diff --git a/generator/config/query/not.yaml b/generator/config/query/not.yaml index 4a843c4fc..930daf725 100644 --- a/generator/config/query/not.yaml +++ b/generator/config/query/not.yaml @@ -18,9 +18,31 @@ tests: price: $not: $gt: 1.99 + schema: + inventory: + price: + types: + - bsonType: Double + qty: + types: + - bsonType: Int32 + sale: + types: + - bsonType: Boolean - name: Regular Expressions - link: https://www.mongodb.com/docs/manual/reference/operator/query/not/#-not-and-regular-expressions + link: https://www.mongodb.com/docs/manual/reference/operator/query/not/#regular-expressions pipeline: - $match: price: $not: !bson_regex ^p.* + schema: + inventory: + price: + types: + - bsonType: Double + qty: + types: + - bsonType: Int32 + sale: + types: + - bsonType: Boolean diff --git a/generator/config/query/or.yaml b/generator/config/query/or.yaml index 57d470731..b1bfca02e 100644 --- a/generator/config/query/or.yaml +++ b/generator/config/query/or.yaml @@ -21,6 +21,17 @@ tests: - quantity: $lt: 20 - price: 10 + schema: + inventory: + price: + types: + - bsonType: Double + qty: + types: + - bsonType: Int32 + sale: + types: + - bsonType: Boolean - name: Error Handling link: https://www.mongodb.com/docs/manual/reference/operator/query/or/#error-handling pipeline: @@ -34,3 +45,8 @@ tests: - 1 - $x - 3 + schema: + example: + x: + types: + - bsonType: Int32 diff --git a/generator/config/query/rand.yaml b/generator/config/query/rand.yaml index 316d972f0..7674f411f 100644 --- a/generator/config/query/rand.yaml +++ b/generator/config/query/rand.yaml @@ -20,3 +20,17 @@ tests: _id: 0 name: 1 registered: 1 + schema: + voters: + name: + types: + - bsonType: String + voterId: + types: + - bsonType: Number + district: + types: + - bsonType: Number + registered: + types: + - bsonType: Boolean diff --git a/generator/config/query/regex.yaml b/generator/config/query/regex.yaml index 9ab5ce6e9..de91f521d 100644 --- a/generator/config/query/regex.yaml +++ b/generator/config/query/regex.yaml @@ -17,6 +17,17 @@ tests: - $match: sku: $regex: !bson_regex 789$ + schema: + products: + _id: + types: + - bsonType: Number + sku: + types: + - bsonType: String + description: + types: + - bsonType: String - 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: @@ -25,3 +36,14 @@ tests: $regex: !bson_regex - ^ABC - i + schema: + products: + _id: + types: + - bsonType: Number + sku: + types: + - bsonType: String + description: + types: + - bsonType: String diff --git a/generator/config/query/sampleRate.yaml b/generator/config/query/sampleRate.yaml index 299719317..125e12d33 100644 --- a/generator/config/query/sampleRate.yaml +++ b/generator/config/query/sampleRate.yaml @@ -20,3 +20,8 @@ tests: - $match: $sampleRate: 0.33 - $count: numMatches + schema: + collection: + _id: + types: + - bsonType: ObjectId diff --git a/generator/config/query/size.yaml b/generator/config/query/size.yaml index e1dbec9c1..cb53048f0 100644 --- a/generator/config/query/size.yaml +++ b/generator/config/query/size.yaml @@ -17,3 +17,14 @@ tests: - $match: tags: $size: 3 + schema: + inventory: + price: + types: + - bsonType: Double + qty: + types: + - bsonType: Int32 + sale: + types: + - bsonType: Boolean diff --git a/generator/config/query/text.yaml b/generator/config/query/text.yaml index 1a6a1c07a..bae9d6c20 100644 --- a/generator/config/query/text.yaml +++ b/generator/config/query/text.yaml @@ -34,32 +34,68 @@ 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 + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#-text-with-a-single-word pipeline: - $match: $text: $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 - pipeline: - - $match: - $text: - $search: bake coffee cake - - name: Search a Different Language - link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#search-a-different-language + schema: + articles: + _id: + types: + - bsonType: Number + subject: + types: + - bsonType: String + author: + types: + - bsonType: String + views: + types: + - bsonType: Number + - name: Query a Different Language + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#query-a-different-language pipeline: - $match: $text: $search: leche $language: es + schema: + articles: + _id: + types: + - bsonType: Number + subject: + types: + - bsonType: String + author: + types: + - bsonType: String + views: + types: + - bsonType: Number - name: Case and Diacritic Insensitive Search - link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#case-and-diacritic-insensitive-search + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#case-and-diacritic-insensitivity pipeline: - $match: $text: $search: сы́рники CAFÉS + schema: + articles: + _id: + types: + - bsonType: Number + subject: + types: + - bsonType: String + author: + types: + - bsonType: String + views: + types: + - bsonType: Number - name: Perform Case Sensitive Search - link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#perform-case-sensitive-search + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#case-sensitivity pipeline: - $match: $text: @@ -69,15 +105,43 @@ tests: $text: $search: \"Café Con Leche\" $caseSensitive: true + schema: + articles: + _id: + types: + - bsonType: Number + subject: + types: + - bsonType: String + author: + types: + - bsonType: String + views: + types: + - bsonType: Number - name: Diacritic Sensitive Search - link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#perform-case-sensitive-search + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#diacritic-sensitivity pipeline: - $match: $text: $search: CAFÉ $diacriticSensitive: true + schema: + articles: + _id: + types: + - bsonType: Number + subject: + types: + - bsonType: String + author: + types: + - bsonType: String + views: + types: + - bsonType: Number - name: Text Search Score Examples - link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#perform-case-sensitive-search + link: https://www.mongodb.com/docs/manual/reference/operator/query/text/#relevance-score-examples pipeline: - $match: $text: @@ -90,3 +154,17 @@ tests: score: $meta: textScore - $limit: 5 + schema: + articles: + _id: + types: + - bsonType: Number + subject: + types: + - bsonType: String + author: + types: + - bsonType: String + views: + types: + - bsonType: Number diff --git a/generator/config/query/type.yaml b/generator/config/query/type.yaml index 208222646..14f3bc656 100644 --- a/generator/config/query/type.yaml +++ b/generator/config/query/type.yaml @@ -36,8 +36,25 @@ tests: zipCode: $type: - number + schema: + addressBook: + _id: + types: + - bsonType: Number + address: + types: + - bsonType: String + zipCode: + types: + - bsonType: String + - bsonType: Number + - bsonType: Long + - bsonType: Int32 + - bsonType: Array + types: + - bsonType: String - name: Querying by Multiple Data Type - link: https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-multiple-data-type + link: https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-multiple-data-types pipeline: - $match: zipCode: @@ -49,6 +66,23 @@ tests: $type: - string - double + schema: + addressBook: + _id: + types: + - bsonType: Number + address: + types: + - bsonType: String + zipCode: + types: + - bsonType: String + - bsonType: Number + - bsonType: Long + - bsonType: Int32 + - bsonType: Array + types: + - bsonType: String - name: Querying by MinKey and MaxKey link: https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-minkey-and-maxkey pipeline: @@ -60,6 +94,23 @@ tests: zipCode: $type: - maxKey + schema: + addressBook: + _id: + types: + - bsonType: Number + address: + types: + - bsonType: String + zipCode: + types: + - bsonType: String + - bsonType: Number + - bsonType: Long + - bsonType: Int32 + - bsonType: Array + types: + - bsonType: String - name: Querying by Array Type link: https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-array-type pipeline: @@ -67,3 +118,18 @@ tests: zipCode: $type: - array + schema: + sensorReading: + _id: + types: + - bsonType: Number + readings: + types: + - bsonType: Array + types: + - bsonType: Number + - bsonType: Array + types: + - bsonType: String + - bsonType: Number + - bsonType: Number diff --git a/generator/config/query/where.yaml b/generator/config/query/where.yaml index 900862387..925e08866 100644 --- a/generator/config/query/where.yaml +++ b/generator/config/query/where.yaml @@ -31,3 +31,17 @@ tests: args: - $name lang: js + schema: + players: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + username: + types: + - bsonType: String + first_login: + types: + - bsonType: String diff --git a/generator/config/schema.json b/generator/config/schema.json index c1c51634f..05a16ec8a 100644 --- a/generator/config/schema.json +++ b/generator/config/schema.json @@ -331,6 +331,7 @@ "Double", "Int32", "Int64", + "Long", "MaxKey", "MinKey", "Null", From 64a44adff7e047576f65e6bb28455d0ad2d3573d Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Thu, 22 May 2025 23:21:56 +0200 Subject: [PATCH 09/16] add search schemas --- generator/config/search/autocomplete.yaml | 147 +++++ generator/config/search/compound.yaml | 85 +++ generator/config/search/embeddedDocument.yaml | 87 +++ generator/config/search/equals.yaml | 294 ++++++++++ generator/config/search/exists.yaml | 72 +++ generator/config/search/facet.yaml | 137 +++++ generator/config/search/geoShape.yaml | 401 +++++++++++++ generator/config/search/geoWithin.yaml | 401 +++++++++++++ generator/config/search/in.yaml | 52 ++ generator/config/search/moreLikeThis.yaml | 141 +++++ generator/config/search/near.yaml | 538 ++++++++++++++++++ generator/config/search/phrase.yaml | 143 +++++ generator/config/search/queryString.yaml | 137 +++++ generator/config/search/range.yaml | 145 +++++ generator/config/search/regex.yaml | 137 +++++ generator/config/search/text.yaml | 151 +++++ generator/config/search/wildcard.yaml | 139 +++++ 17 files changed, 3207 insertions(+) diff --git a/generator/config/search/autocomplete.yaml b/generator/config/search/autocomplete.yaml index 8a544b768..b4bde643d 100644 --- a/generator/config/search/autocomplete.yaml +++ b/generator/config/search/autocomplete.yaml @@ -40,6 +40,143 @@ tests: - $project: _id: 0 title: 1 + schema: + movies: &ref_0 + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String - name: Fuzzy link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#fuzzy-example pipeline: @@ -55,6 +192,8 @@ tests: - $project: _id: 0 title: 1 + schema: + movies: *ref_0 - name: Token Order any link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#simple-any-example pipeline: @@ -67,6 +206,8 @@ tests: - $project: _id: 0 title: 1 + schema: + movies: *ref_0 - name: Token Order sequential link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#simple-sequential-example pipeline: @@ -79,6 +220,8 @@ tests: - $project: _id: 0 title: 1 + schema: + movies: *ref_0 - name: Highlighting link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#highlighting-example pipeline: @@ -96,6 +239,8 @@ tests: title: 1 highlights: $meta: searchHighlights + schema: + movies: *ref_0 - name: Across Multiple Fields link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#search-across-multiple-fields pipeline: @@ -114,3 +259,5 @@ tests: _id: 0 title: 1 plot: 1 + schema: + movies: *ref_0 diff --git a/generator/config/search/compound.yaml b/generator/config/search/compound.yaml index 50fc502cc..5c547fd94 100644 --- a/generator/config/search/compound.yaml +++ b/generator/config/search/compound.yaml @@ -51,6 +51,23 @@ tests: - text: query: apples path: description + schema: + TestCollection: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + description: + types: + - bsonType: String + category: + types: + - bsonType: String + in_stock: + types: + - bsonType: Boolean - name: must and should link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#must-and-should-example pipeline: @@ -67,6 +84,23 @@ tests: - $project: score: $meta: searchScore + schema: + TestCollection: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + description: + types: + - bsonType: String + category: + types: + - bsonType: String + in_stock: + types: + - bsonType: Boolean - name: minimumShouldMatch link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#minimumshouldmatch-example pipeline: @@ -84,6 +118,23 @@ tests: query: Golden Delicious path: description minimumShouldMatch: 1 + schema: + TestCollection: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + description: + types: + - bsonType: String + category: + types: + - bsonType: String + in_stock: + types: + - bsonType: Boolean - name: Filter link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#filter-examples pipeline: @@ -101,6 +152,23 @@ tests: - text: query: granny path: description + schema: + TestCollection: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + description: + types: + - bsonType: String + category: + types: + - bsonType: String + in_stock: + types: + - bsonType: Boolean - name: Nested link: https://www.mongodb.com/docs/atlas/atlas-search/compound/#nested-example pipeline: @@ -119,3 +187,20 @@ tests: value: true path: in_stock minimumShouldMatch: 1 + schema: + TestCollection: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + description: + types: + - bsonType: String + category: + types: + - bsonType: String + in_stock: + types: + - bsonType: Boolean diff --git a/generator/config/search/embeddedDocument.yaml b/generator/config/search/embeddedDocument.yaml index 17f68f5ee..58295586a 100644 --- a/generator/config/search/embeddedDocument.yaml +++ b/generator/config/search/embeddedDocument.yaml @@ -47,6 +47,87 @@ tests: items.tags: 1 score: $meta: searchScore + schema: + sales: &ref_0 + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + saleDate: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + items: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + tags: + types: + - bsonType: Array + types: + - bsonType: String + price: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + quantity: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + storeLocation: + types: + - bsonType: String + customer: + types: + - bsonType: Document + fields: + gender: + types: + - bsonType: String + age: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + email: + types: + - bsonType: String + satisfaction: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + couponUsed: + types: + - bsonType: Boolean + purchaseMethod: + types: + - bsonType: String - name: Facet link: https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#facet-query pipeline: @@ -69,6 +150,8 @@ tests: purchaseMethodFacet: type: string path: purchaseMethod + schema: + sales: *ref_0 - name: Query and Sort link: https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#query-and-sort pipeline: @@ -88,6 +171,8 @@ tests: items.tags: 1 score: $meta: searchScore + schema: + sales: *ref_0 - 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: @@ -123,3 +208,5 @@ tests: - $in: - office - $$this.tags + schema: + sales: *ref_0 diff --git a/generator/config/search/equals.yaml b/generator/config/search/equals.yaml index d04115d18..65c2abdfe 100644 --- a/generator/config/search/equals.yaml +++ b/generator/config/search/equals.yaml @@ -36,6 +36,48 @@ tests: _id: 0 score: $meta: searchScore + schema: + users: + _id: + types: + - bsonType: ObjectId + name: + types: + - bsonType: String + verified_user: + types: + - bsonType: Boolean + account: + types: + - bsonType: Document + fields: + new_user: + types: + - bsonType: Boolean + active_user: + types: + - bsonType: Boolean + teammates: + types: + - bsonType: Array + types: + - bsonType: ObjectId + region: + types: + - bsonType: String + account_created: + types: + - bsonType: Date + employee_number: + types: + - bsonType: Number + uuid: + types: + - bsonType: Binary + job_title: + types: + - bsonType: 'Null' + - bsonType: String - name: ObjectId link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#objectid-example pipeline: @@ -43,6 +85,48 @@ tests: equals: path: teammates value: !bson_objectId 5a9427648b0beebeb69589a1 + schema: + users: + _id: + types: + - bsonType: ObjectId + name: + types: + - bsonType: String + verified_user: + types: + - bsonType: Boolean + account: + types: + - bsonType: Document + fields: + new_user: + types: + - bsonType: Boolean + active_user: + types: + - bsonType: Boolean + teammates: + types: + - bsonType: Array + types: + - bsonType: ObjectId + region: + types: + - bsonType: String + account_created: + types: + - bsonType: Date + employee_number: + types: + - bsonType: Number + uuid: + types: + - bsonType: Binary + job_title: + types: + - bsonType: 'Null' + - bsonType: String - name: Date link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#date-example pipeline: @@ -50,6 +134,48 @@ tests: equals: path: account_created value: !bson_utcdatetime '2022-05-04T05:01:08.000Z' + schema: + users: + _id: + types: + - bsonType: ObjectId + name: + types: + - bsonType: String + verified_user: + types: + - bsonType: Boolean + account: + types: + - bsonType: Document + fields: + new_user: + types: + - bsonType: Boolean + active_user: + types: + - bsonType: Boolean + teammates: + types: + - bsonType: Array + types: + - bsonType: ObjectId + region: + types: + - bsonType: String + account_created: + types: + - bsonType: Date + employee_number: + types: + - bsonType: Number + uuid: + types: + - bsonType: Binary + job_title: + types: + - bsonType: 'Null' + - bsonType: String - name: Number link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#number-example pipeline: @@ -57,6 +183,48 @@ tests: equals: path: employee_number value: 259 + schema: + users: + _id: + types: + - bsonType: ObjectId + name: + types: + - bsonType: String + verified_user: + types: + - bsonType: Boolean + account: + types: + - bsonType: Document + fields: + new_user: + types: + - bsonType: Boolean + active_user: + types: + - bsonType: Boolean + teammates: + types: + - bsonType: Array + types: + - bsonType: ObjectId + region: + types: + - bsonType: String + account_created: + types: + - bsonType: Date + employee_number: + types: + - bsonType: Number + uuid: + types: + - bsonType: Binary + job_title: + types: + - bsonType: 'Null' + - bsonType: String - name: String link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#string-example pipeline: @@ -64,6 +232,48 @@ tests: equals: path: name value: jim hall + schema: + users: + _id: + types: + - bsonType: ObjectId + name: + types: + - bsonType: String + verified_user: + types: + - bsonType: Boolean + account: + types: + - bsonType: Document + fields: + new_user: + types: + - bsonType: Boolean + active_user: + types: + - bsonType: Boolean + teammates: + types: + - bsonType: Array + types: + - bsonType: ObjectId + region: + types: + - bsonType: String + account_created: + types: + - bsonType: Date + employee_number: + types: + - bsonType: Number + uuid: + types: + - bsonType: Binary + job_title: + types: + - bsonType: 'Null' + - bsonType: String - name: UUID link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#uuid-example pipeline: @@ -71,6 +281,48 @@ tests: equals: path: uuid value: !bson_uuid fac32260-b511-4c69-8485-a2be5b7dda9e + schema: + users: + _id: + types: + - bsonType: ObjectId + name: + types: + - bsonType: String + verified_user: + types: + - bsonType: Boolean + account: + types: + - bsonType: Document + fields: + new_user: + types: + - bsonType: Boolean + active_user: + types: + - bsonType: Boolean + teammates: + types: + - bsonType: Array + types: + - bsonType: ObjectId + region: + types: + - bsonType: String + account_created: + types: + - bsonType: Date + employee_number: + types: + - bsonType: Number + uuid: + types: + - bsonType: Binary + job_title: + types: + - bsonType: 'Null' + - bsonType: String - name: 'Null' link: https://www.mongodb.com/docs/atlas/atlas-search/equals/#null-example pipeline: @@ -78,3 +330,45 @@ tests: equals: path: job_title value: ~ + schema: + users: + _id: + types: + - bsonType: ObjectId + name: + types: + - bsonType: String + verified_user: + types: + - bsonType: Boolean + account: + types: + - bsonType: Document + fields: + new_user: + types: + - bsonType: Boolean + active_user: + types: + - bsonType: Boolean + teammates: + types: + - bsonType: Array + types: + - bsonType: ObjectId + region: + types: + - bsonType: String + account_created: + types: + - bsonType: Date + employee_number: + types: + - bsonType: Number + uuid: + types: + - bsonType: Binary + job_title: + types: + - bsonType: 'Null' + - bsonType: String diff --git a/generator/config/search/exists.yaml b/generator/config/search/exists.yaml index a339b7b06..5e49f56d2 100644 --- a/generator/config/search/exists.yaml +++ b/generator/config/search/exists.yaml @@ -21,12 +21,60 @@ tests: - $search: exists: path: type + schema: + TestCollection: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + description: + types: + - bsonType: String + quantities: + types: + - bsonType: Document + fields: + lemons: + types: + - bsonType: Number + oranges: + types: + - bsonType: Number + grapefruit: + types: + - bsonType: Number - name: Embedded link: https://www.mongodb.com/docs/atlas/atlas-search/exists/#embedded-example pipeline: - $search: exists: path: quantities.lemons + schema: + TestCollection: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + description: + types: + - bsonType: String + quantities: + types: + - bsonType: Document + fields: + lemons: + types: + - bsonType: Number + oranges: + types: + - bsonType: Number + grapefruit: + types: + - bsonType: Number - name: Compound link: https://www.mongodb.com/docs/atlas/atlas-search/exists/#compound-example pipeline: @@ -42,3 +90,27 @@ tests: text: query: fuji path: description + schema: + TestCollection: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + description: + types: + - bsonType: String + quantities: + types: + - bsonType: Document + fields: + lemons: + types: + - bsonType: Number + oranges: + types: + - bsonType: Number + grapefruit: + types: + - bsonType: Number diff --git a/generator/config/search/facet.yaml b/generator/config/search/facet.yaml index a8aff34ba..9cfd0f499 100644 --- a/generator/config/search/facet.yaml +++ b/generator/config/search/facet.yaml @@ -44,3 +44,140 @@ tests: $arrayElemAt: - $meta - 0 + schema: + movies: + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String diff --git a/generator/config/search/geoShape.yaml b/generator/config/search/geoShape.yaml index d7b1080e7..23e8bcc60 100644 --- a/generator/config/search/geoShape.yaml +++ b/generator/config/search/geoShape.yaml @@ -47,6 +47,403 @@ tests: address: 1 score: $meta: searchScore + schema: + listingsAndReviews: &ref_0 + _id: + types: + - bsonType: String + listing_url: + types: + - bsonType: String + name: + types: + - bsonType: String + summary: + types: + - bsonType: String + interaction: + types: + - bsonType: String + house_rules: + types: + - bsonType: String + property_type: + types: + - bsonType: String + room_type: + types: + - bsonType: String + bed_type: + types: + - bsonType: String + minimum_nights: + types: + - bsonType: String + maximum_nights: + types: + - bsonType: String + cancellation_policy: + types: + - bsonType: String + last_scraped: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + calendar_last_scraped: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + first_review: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + last_review: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + accommodates: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + bedrooms: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + beds: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + number_of_reviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + bathrooms: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + amenities: + types: + - bsonType: Array + types: + - bsonType: String + price: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + security_deposit: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + cleaning_fee: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + extra_people: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + guests_included: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + images: + types: + - bsonType: Document + fields: + thumbnail_url: + types: + - bsonType: String + medium_url: + types: + - bsonType: String + picture_url: + types: + - bsonType: String + xl_picture_url: + types: + - bsonType: String + host: + types: + - bsonType: Document + fields: + host_id: + types: + - bsonType: String + host_url: + types: + - bsonType: String + host_name: + types: + - bsonType: String + host_location: + types: + - bsonType: String + host_about: + types: + - bsonType: String + host_response_time: + types: + - bsonType: String + host_thumbnail_url: + types: + - bsonType: String + host_picture_url: + types: + - bsonType: String + host_neighbourhood: + types: + - bsonType: String + host_response_rate: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + host_is_superhost: + types: + - bsonType: Boolean + host_has_profile_pic: + types: + - bsonType: Boolean + host_identity_verified: + types: + - bsonType: Boolean + host_listings_count: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + host_total_listings_count: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + host_verifications: + types: + - bsonType: Array + types: + - bsonType: String + address: + types: + - bsonType: Document + fields: + street: + types: + - bsonType: String + suburb: + types: + - bsonType: String + government_area: + types: + - bsonType: String + market: + types: + - bsonType: String + country: + types: + - bsonType: String + country_code: + types: + - bsonType: String + location: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + is_location_exact: + types: + - bsonType: Boolean + availability: + types: + - bsonType: Document + fields: + availability_30: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + availability_60: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + availability_90: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + availability_365: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores: + types: + - bsonType: Document + fields: + review_scores_accuracy: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_cleanliness: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_checkin: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_communication: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_location: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_value: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_rating: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + reviews: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + _id: + types: + - bsonType: String + date: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + listing_id: + types: + - bsonType: String + reviewer_id: + types: + - bsonType: String + reviewer_name: + types: + - bsonType: String + comments: + types: + - bsonType: String - name: Intersect link: https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#intersects-example pipeline: @@ -88,6 +485,8 @@ tests: address: 1 score: $meta: searchScore + schema: + listingsAndReviews: *ref_0 - name: Within link: https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#within-example pipeline: @@ -121,3 +520,5 @@ tests: address: 1 score: $meta: searchScore + schema: + listingsAndReviews: *ref_0 diff --git a/generator/config/search/geoWithin.yaml b/generator/config/search/geoWithin.yaml index 5a79865b2..08b7f72c9 100644 --- a/generator/config/search/geoWithin.yaml +++ b/generator/config/search/geoWithin.yaml @@ -51,6 +51,403 @@ tests: _id: 0 name: 1 address: 1 + schema: + listingsAndReviews: &ref_0 + _id: + types: + - bsonType: String + listing_url: + types: + - bsonType: String + name: + types: + - bsonType: String + summary: + types: + - bsonType: String + interaction: + types: + - bsonType: String + house_rules: + types: + - bsonType: String + property_type: + types: + - bsonType: String + room_type: + types: + - bsonType: String + bed_type: + types: + - bsonType: String + minimum_nights: + types: + - bsonType: String + maximum_nights: + types: + - bsonType: String + cancellation_policy: + types: + - bsonType: String + last_scraped: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + calendar_last_scraped: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + first_review: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + last_review: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + accommodates: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + bedrooms: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + beds: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + number_of_reviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + bathrooms: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + amenities: + types: + - bsonType: Array + types: + - bsonType: String + price: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + security_deposit: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + cleaning_fee: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + extra_people: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + guests_included: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + images: + types: + - bsonType: Document + fields: + thumbnail_url: + types: + - bsonType: String + medium_url: + types: + - bsonType: String + picture_url: + types: + - bsonType: String + xl_picture_url: + types: + - bsonType: String + host: + types: + - bsonType: Document + fields: + host_id: + types: + - bsonType: String + host_url: + types: + - bsonType: String + host_name: + types: + - bsonType: String + host_location: + types: + - bsonType: String + host_about: + types: + - bsonType: String + host_response_time: + types: + - bsonType: String + host_thumbnail_url: + types: + - bsonType: String + host_picture_url: + types: + - bsonType: String + host_neighbourhood: + types: + - bsonType: String + host_response_rate: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + host_is_superhost: + types: + - bsonType: Boolean + host_has_profile_pic: + types: + - bsonType: Boolean + host_identity_verified: + types: + - bsonType: Boolean + host_listings_count: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + host_total_listings_count: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + host_verifications: + types: + - bsonType: Array + types: + - bsonType: String + address: + types: + - bsonType: Document + fields: + street: + types: + - bsonType: String + suburb: + types: + - bsonType: String + government_area: + types: + - bsonType: String + market: + types: + - bsonType: String + country: + types: + - bsonType: String + country_code: + types: + - bsonType: String + location: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + is_location_exact: + types: + - bsonType: Boolean + availability: + types: + - bsonType: Document + fields: + availability_30: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + availability_60: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + availability_90: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + availability_365: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores: + types: + - bsonType: Document + fields: + review_scores_accuracy: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_cleanliness: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_checkin: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_communication: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_location: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_value: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_rating: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + reviews: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + _id: + types: + - bsonType: String + date: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + listing_id: + types: + - bsonType: String + reviewer_id: + types: + - bsonType: String + reviewer_name: + types: + - bsonType: String + comments: + types: + - bsonType: String - name: circle link: https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#circle-example pipeline: @@ -69,6 +466,8 @@ tests: _id: 0 name: 1 address: 1 + schema: + listingsAndReviews: *ref_0 - name: geometry link: https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#geometry-examples pipeline: @@ -91,3 +490,5 @@ tests: _id: 0 name: 1 address: 1 + schema: + listingsAndReviews: *ref_0 diff --git a/generator/config/search/in.yaml b/generator/config/search/in.yaml index 37b9e18a7..cd1688aac 100644 --- a/generator/config/search/in.yaml +++ b/generator/config/search/in.yaml @@ -33,6 +33,54 @@ tests: _id: 0 name: 1 birthdate: 1 + schema: + customers: &ref_0 + username: + types: + - bsonType: String + name: + types: + - bsonType: String + address: + types: + - bsonType: String + birthdate: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Double + email: + types: + - bsonType: String + accounts: + types: + - bsonType: Array + types: + - bsonType: Double + tier_and_details: + types: + - bsonType: Document + fields: + b5f19cb532fa436a9be2cf1d7d1cac8a: + types: + - bsonType: Document + fields: + tier: + types: + - bsonType: String + benefits: + types: + - bsonType: Array + types: + - bsonType: String + active: + types: + - bsonType: Boolean + id: + types: + - bsonType: String - name: Array Value Field Match link: https://www.mongodb.com/docs/atlas/atlas-search/in/#examples pipeline: @@ -47,6 +95,8 @@ tests: _id: 0 name: 1 accounts: 1 + schema: + customers: *ref_0 - name: Compound Query Match link: https://www.mongodb.com/docs/atlas/atlas-search/in/#examples pipeline: @@ -70,3 +120,5 @@ tests: name: 1 score: $meta: searchScore + schema: + customers: *ref_0 diff --git a/generator/config/search/moreLikeThis.yaml b/generator/config/search/moreLikeThis.yaml index 6fd005c3b..008860d0a 100644 --- a/generator/config/search/moreLikeThis.yaml +++ b/generator/config/search/moreLikeThis.yaml @@ -32,6 +32,143 @@ tests: title: 1 released: 1 genres: 1 + schema: + movies: &ref_0 + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String - name: Input Document Excluded in Results link: https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-2--input-document-excluded-in-results pipeline: @@ -55,6 +192,8 @@ tests: title: 1 released: 1 genres: 1 + schema: + movies: *ref_0 - name: Multiple Analyzers link: https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-3--multiple-analyzers pipeline: @@ -77,3 +216,5 @@ tests: title: 1 genres: 1 _id: 1 + schema: + movies: *ref_0 diff --git a/generator/config/search/near.yaml b/generator/config/search/near.yaml index f4f7c0867..2c00ae424 100644 --- a/generator/config/search/near.yaml +++ b/generator/config/search/near.yaml @@ -39,6 +39,143 @@ tests: runtime: 1 score: $meta: searchScore + schema: + movies: &ref_0 + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String - name: Date link: https://www.mongodb.com/docs/atlas/atlas-search/near/#date-example pipeline: @@ -55,6 +192,8 @@ tests: released: 1 score: $meta: searchScore + schema: + movies: *ref_0 - name: GeoJSON Point link: https://www.mongodb.com/docs/atlas/atlas-search/near/#geojson-point-examples pipeline: @@ -74,6 +213,403 @@ tests: address: 1 score: $meta: searchScore + schema: + listingsAndReviews: &ref_1 + _id: + types: + - bsonType: String + listing_url: + types: + - bsonType: String + name: + types: + - bsonType: String + summary: + types: + - bsonType: String + interaction: + types: + - bsonType: String + house_rules: + types: + - bsonType: String + property_type: + types: + - bsonType: String + room_type: + types: + - bsonType: String + bed_type: + types: + - bsonType: String + minimum_nights: + types: + - bsonType: String + maximum_nights: + types: + - bsonType: String + cancellation_policy: + types: + - bsonType: String + last_scraped: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + calendar_last_scraped: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + first_review: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + last_review: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + accommodates: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + bedrooms: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + beds: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + number_of_reviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + bathrooms: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + amenities: + types: + - bsonType: Array + types: + - bsonType: String + price: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + security_deposit: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + cleaning_fee: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + extra_people: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + guests_included: + types: + - bsonType: Document + fields: + $numberDecimal: + types: + - bsonType: String + images: + types: + - bsonType: Document + fields: + thumbnail_url: + types: + - bsonType: String + medium_url: + types: + - bsonType: String + picture_url: + types: + - bsonType: String + xl_picture_url: + types: + - bsonType: String + host: + types: + - bsonType: Document + fields: + host_id: + types: + - bsonType: String + host_url: + types: + - bsonType: String + host_name: + types: + - bsonType: String + host_location: + types: + - bsonType: String + host_about: + types: + - bsonType: String + host_response_time: + types: + - bsonType: String + host_thumbnail_url: + types: + - bsonType: String + host_picture_url: + types: + - bsonType: String + host_neighbourhood: + types: + - bsonType: String + host_response_rate: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + host_is_superhost: + types: + - bsonType: Boolean + host_has_profile_pic: + types: + - bsonType: Boolean + host_identity_verified: + types: + - bsonType: Boolean + host_listings_count: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + host_total_listings_count: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + host_verifications: + types: + - bsonType: Array + types: + - bsonType: String + address: + types: + - bsonType: Document + fields: + street: + types: + - bsonType: String + suburb: + types: + - bsonType: String + government_area: + types: + - bsonType: String + market: + types: + - bsonType: String + country: + types: + - bsonType: String + country_code: + types: + - bsonType: String + location: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + is_location_exact: + types: + - bsonType: Boolean + availability: + types: + - bsonType: Document + fields: + availability_30: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + availability_60: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + availability_90: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + availability_365: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores: + types: + - bsonType: Document + fields: + review_scores_accuracy: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_cleanliness: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_checkin: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_communication: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_location: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_value: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + review_scores_rating: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + reviews: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + _id: + types: + - bsonType: String + date: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + listing_id: + types: + - bsonType: String + reviewer_id: + types: + - bsonType: String + reviewer_name: + types: + - bsonType: String + comments: + types: + - bsonType: String - name: Compound link: https://www.mongodb.com/docs/atlas/atlas-search/near/#compound-example pipeline: @@ -99,3 +635,5 @@ tests: address: 1 score: $meta: searchScore + schema: + listingsAndReviews: *ref_1 diff --git a/generator/config/search/phrase.yaml b/generator/config/search/phrase.yaml index d2bfe1eb0..63c1ad5d4 100644 --- a/generator/config/search/phrase.yaml +++ b/generator/config/search/phrase.yaml @@ -40,6 +40,143 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: &ref_0 + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String - name: Multiple Phrase link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/#multiple-phrases-example pipeline: @@ -55,6 +192,8 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: *ref_0 - name: Phrase Slop link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/#slop-example pipeline: @@ -68,6 +207,8 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: *ref_0 - name: Phrase Synonyms link: https://www.mongodb.com/docs/atlas/atlas-search/phrase/#synonyms-example pipeline: @@ -84,3 +225,5 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: *ref_0 diff --git a/generator/config/search/queryString.yaml b/generator/config/search/queryString.yaml index c31bbdbb3..e3625270a 100644 --- a/generator/config/search/queryString.yaml +++ b/generator/config/search/queryString.yaml @@ -23,3 +23,140 @@ tests: - $project: _id: 0 title: 1 + schema: + movies: + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String diff --git a/generator/config/search/range.yaml b/generator/config/search/range.yaml index 1a9cc10c5..da8226537 100644 --- a/generator/config/search/range.yaml +++ b/generator/config/search/range.yaml @@ -57,6 +57,143 @@ tests: _id: 0 title: 1 runtime: 1 + schema: + movies: &ref_0 + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String - name: Number lte link: https://www.mongodb.com/docs/atlas/atlas-search/range/#number-example pipeline: @@ -71,6 +208,8 @@ tests: runtime: 1 score: $meta: searchScore + schema: + movies: *ref_0 - name: Date link: https://www.mongodb.com/docs/atlas/atlas-search/range/#date-example pipeline: @@ -84,6 +223,8 @@ tests: _id: 0 title: 1 released: 1 + schema: + movies: *ref_0 - name: ObjectId link: https://www.mongodb.com/docs/atlas/atlas-search/range/#objectid-example pipeline: @@ -96,6 +237,8 @@ tests: _id: 1 title: 1 released: 1 + schema: + movies: *ref_0 - name: String link: https://www.mongodb.com/docs/atlas/atlas-search/range/#string-example pipeline: @@ -108,3 +251,5 @@ tests: - $project: _id: 0 title: 1 + schema: + movies: *ref_0 diff --git a/generator/config/search/regex.yaml b/generator/config/search/regex.yaml index 44d733491..028bc364d 100644 --- a/generator/config/search/regex.yaml +++ b/generator/config/search/regex.yaml @@ -33,3 +33,140 @@ tests: - $project: _id: 0 title: 1 + schema: + movies: + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String diff --git a/generator/config/search/text.yaml b/generator/config/search/text.yaml index 0e88cad6b..1ef63552f 100644 --- a/generator/config/search/text.yaml +++ b/generator/config/search/text.yaml @@ -43,6 +43,143 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: &ref_0 + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String - name: Fuzzy Default link: https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples pipeline: @@ -57,6 +194,8 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: *ref_0 - name: Fuzzy maxExpansions link: https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples pipeline: @@ -73,6 +212,8 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: *ref_0 - name: Fuzzy prefixLength link: https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples pipeline: @@ -89,6 +230,8 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: *ref_0 - name: Match any Using equivalent Mapping link: https://www.mongodb.com/docs/atlas/atlas-search/text/#match-any-using-equivalent-mapping pipeline: @@ -105,6 +248,8 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: *ref_0 - name: Match any Using explicit Mapping link: https://www.mongodb.com/docs/atlas/atlas-search/text/#match-any-using-explicit-mapping pipeline: @@ -121,6 +266,8 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: *ref_0 - name: Match all Using Synonyms link: https://www.mongodb.com/docs/atlas/atlas-search/text/#match-all-using-synonyms pipeline: @@ -137,6 +284,8 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: *ref_0 - name: Wildcard Path link: https://www.mongodb.com/docs/atlas/atlas-search/text/ pipeline: @@ -150,3 +299,5 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: *ref_0 diff --git a/generator/config/search/wildcard.yaml b/generator/config/search/wildcard.yaml index e6b346d83..9e66395ef 100644 --- a/generator/config/search/wildcard.yaml +++ b/generator/config/search/wildcard.yaml @@ -34,6 +34,143 @@ tests: - $project: _id: 0 title: 1 + schema: + movies: &ref_0 + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String - name: Escape Character Example link: https://www.mongodb.com/docs/atlas/atlas-search/wildcard/#escape-character-example pipeline: @@ -45,3 +182,5 @@ tests: - $project: _id: 0 title: 1 + schema: + movies: *ref_0 From 6a34eda7eab0e890b58679649d77082dbbb056bc Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Fri, 23 May 2025 16:20:24 +0200 Subject: [PATCH 10/16] schema for stages --- generator/config/stage/addFields.yaml | 71 +++++++ generator/config/stage/bucket.yaml | 37 ++++ generator/config/stage/bucketAuto.yaml | 30 +++ generator/config/stage/changeStream.yaml | 5 + .../stage/changeStreamSplitLargeEvent.yaml | 8 + generator/config/stage/collStats.yaml | 11 + generator/config/stage/count.yaml | 13 +- generator/config/stage/currentOp.yaml | 7 + generator/config/stage/densify.yaml | 34 ++- generator/config/stage/documents.yaml | 13 ++ generator/config/stage/facet.yaml | 22 ++ generator/config/stage/fill.yaml | 49 +++++ generator/config/stage/geoNear.yaml | 108 ++++++++++ generator/config/stage/graphLookup.yaml | 42 ++++ generator/config/stage/group.yaml | 116 ++++++++++ generator/config/stage/indexStats.yaml | 17 ++ generator/config/stage/limit.yaml | 5 + generator/config/stage/listLocalSessions.yaml | 9 + .../config/stage/listSampledQueries.yaml | 7 + generator/config/stage/listSearchIndexes.yaml | 9 + generator/config/stage/listSessions.yaml | 9 + generator/config/stage/lookup.yaml | 79 +++++++ generator/config/stage/match.yaml | 28 +++ generator/config/stage/merge.yaml | 96 +++++++++ generator/config/stage/out.yaml | 28 +++ generator/config/stage/planCacheStats.yaml | 34 +++ generator/config/stage/project.yaml | 201 ++++++++++++++++++ generator/config/stage/redact.yaml | 86 ++++++++ generator/config/stage/replaceRoot.yaml | 78 +++++++ generator/config/stage/replaceWith.yaml | 81 +++++++ generator/config/stage/sample.yaml | 16 +- generator/config/stage/search.yaml | 157 +++++++++++++- generator/config/stage/searchMeta.yaml | 147 ++++++++++++- generator/config/stage/set.yaml | 92 ++++++++ generator/config/stage/setWindowFields.yaml | 140 ++++++++++++ .../config/stage/shardedDataDistribution.yaml | 5 + generator/config/stage/skip.yaml | 7 +- generator/config/stage/sort.yaml | 13 ++ generator/config/stage/sortByCount.yaml | 21 +- generator/config/stage/unionWith.yaml | 22 ++ generator/config/stage/unset.yaml | 99 +++++++++ generator/config/stage/unwind.yaml | 82 +++++++ generator/config/stage/vectorSearch.yaml | 35 ++- 43 files changed, 2160 insertions(+), 9 deletions(-) diff --git a/generator/config/stage/addFields.yaml b/generator/config/stage/addFields.yaml index 97a916364..1a4ee3a56 100644 --- a/generator/config/stage/addFields.yaml +++ b/generator/config/stage/addFields.yaml @@ -30,16 +30,66 @@ tests: - $totalHomework - $totalQuiz - $extraCredit + schema: + scores: + _id: + types: + - bsonType: Number + student: + types: + - bsonType: String + homework: + types: + - bsonType: Array + types: + - bsonType: Number + quiz: + types: + - bsonType: Array + types: + - bsonType: Number + extraCredit: + types: + - bsonType: Number - 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 + schema: + vehicles: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + specs: + types: + - bsonType: Document + fields: + doors: + types: + - bsonType: Number + wheels: + types: + - bsonType: Number - name: Overwriting an existing field link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#overwriting-an-existing-field pipeline: - $addFields: cats: 20 + schema: + animals: + _id: + types: + - bsonType: Number + dogs: + types: + - bsonType: Number + cats: + types: + - bsonType: Number - name: Add Element to an Array link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#add-element-to-an-array pipeline: @@ -50,3 +100,24 @@ tests: $concatArrays: - $homework - - 7 + schema: + scores: + _id: + types: + - bsonType: Number + student: + types: + - bsonType: String + homework: + types: + - bsonType: Array + types: + - bsonType: Number + quiz: + types: + - bsonType: Array + types: + - bsonType: Number + extraCredit: + types: + - bsonType: Number diff --git a/generator/config/stage/bucket.yaml b/generator/config/stage/bucket.yaml index 6c4968dfe..e6bdeeb32 100644 --- a/generator/config/stage/bucket.yaml +++ b/generator/config/stage/bucket.yaml @@ -63,6 +63,26 @@ tests: - $match: count: $gt: 3 + schema: + artists: + _id: + types: + - bsonType: Number + last_name: + types: + - bsonType: String + first_name: + types: + - bsonType: String + year_born: + types: + - bsonType: Number + year_died: + types: + - bsonType: Number + nationality: + types: + - bsonType: String - 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: @@ -100,3 +120,20 @@ tests: $push: title: $title year: $year + schema: + artwork: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + artist: + types: + - bsonType: String + year: + types: + - bsonType: Number + price: + types: + - bsonType: Decimal128 diff --git a/generator/config/stage/bucketAuto.yaml b/generator/config/stage/bucketAuto.yaml index 32402f7c9..e064995ab 100644 --- a/generator/config/stage/bucketAuto.yaml +++ b/generator/config/stage/bucketAuto.yaml @@ -38,3 +38,33 @@ tests: - $bucketAuto: groupBy: $price buckets: 4 + schema: + artwork: + _id: + types: + - bsonType: Int32 + title: + types: + - bsonType: String + artist: + types: + - bsonType: String + year: + types: + - bsonType: Int32 + price: + types: + - bsonType: Decimal128 + dimensions: + types: + - bsonType: Document + fields: + height: + types: + - bsonType: Int32 + width: + types: + - bsonType: Int32 + units: + types: + - bsonType: String diff --git a/generator/config/stage/changeStream.yaml b/generator/config/stage/changeStream.yaml index fd38c484c..d7518d4a5 100644 --- a/generator/config/stage/changeStream.yaml +++ b/generator/config/stage/changeStream.yaml @@ -55,3 +55,8 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/#examples pipeline: - $changeStream: {} + schema: + names: + _id: + types: + - bsonType: ObjectId diff --git a/generator/config/stage/changeStreamSplitLargeEvent.yaml b/generator/config/stage/changeStreamSplitLargeEvent.yaml index d44451dd1..6d2440306 100644 --- a/generator/config/stage/changeStreamSplitLargeEvent.yaml +++ b/generator/config/stage/changeStreamSplitLargeEvent.yaml @@ -12,3 +12,11 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStreamSplitLargeEvent/#example pipeline: - $changeStreamSplitLargeEvent: {} + schema: + myCollection: + _id: + types: + - bsonType: Int32 + largeField: + types: + - bsonType: String diff --git a/generator/config/stage/collStats.yaml b/generator/config/stage/collStats.yaml index f64799103..e3e70114f 100644 --- a/generator/config/stage/collStats.yaml +++ b/generator/config/stage/collStats.yaml @@ -30,18 +30,29 @@ tests: - $collStats: latencyStats: histograms: true + schema: + TestCollection: &ref_0 + _id: + types: + - bsonType: ObjectId - name: storageStats Document link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#storagestats-document pipeline: - $collStats: storageStats: {} + schema: + TestCollection: *ref_0 - name: count Field link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#count-field pipeline: - $collStats: count: {} + schema: + TestCollection: *ref_0 - name: queryExecStats Document link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#queryexecstats-document pipeline: - $collStats: queryExecStats: {} + schema: + TestCollection: *ref_0 diff --git a/generator/config/stage/count.yaml b/generator/config/stage/count.yaml index 9774878e5..a9dc2a581 100644 --- a/generator/config/stage/count.yaml +++ b/generator/config/stage/count.yaml @@ -15,9 +15,20 @@ 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 + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/#examples pipeline: - $match: score: $gt: 80 - $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 62cf3c2a9..a6ea9620b 100644 --- a/generator/config/stage/currentOp.yaml +++ b/generator/config/stage/currentOp.yaml @@ -38,6 +38,11 @@ tests: active: false transaction: $exists: true + schema: + TestCollection: &ref_0 + _id: + types: + - bsonType: ObjectId - name: Sampled Queries link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/#sampled-queries pipeline: @@ -46,3 +51,5 @@ tests: localOps: true - $match: desc: query analyzer + schema: + TestCollection: *ref_0 diff --git a/generator/config/stage/densify.yaml b/generator/config/stage/densify.yaml index 42f55e8c3..50c0330bc 100644 --- a/generator/config/stage/densify.yaml +++ b/generator/config/stage/densify.yaml @@ -37,8 +37,26 @@ tests: bounds: - !bson_utcdatetime '2021-05-18T00:00:00.000Z' - !bson_utcdatetime '2021-05-18T08:00:00.000Z' + schema: + weather: + metadata: + types: + - bsonType: Document + fields: + sensorId: + types: + - bsonType: Number + type: + types: + - bsonType: String + timestamp: + types: + - bsonType: Date + temp: + types: + - bsonType: Number - name: Densifiction with Partitions - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/#densifiction-with-partitions + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/#densification-with-partitions pipeline: - $densify: field: altitude @@ -47,3 +65,17 @@ tests: range: bounds: full step: 200 + schema: + coffee: + altitude: + types: + - bsonType: Number + variety: + types: + - bsonType: String + score: + types: + - bsonType: Number + price: + types: + - bsonType: Number diff --git a/generator/config/stage/documents.yaml b/generator/config/stage/documents.yaml index 6f4b6fe29..1f9ec211f 100644 --- a/generator/config/stage/documents.yaml +++ b/generator/config/stage/documents.yaml @@ -27,6 +27,11 @@ tests: - $bucketAuto: groupBy: $x buckets: 4 + schema: + TestCollection: + x: + types: + - bsonType: Number - 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: @@ -41,3 +46,11 @@ tests: name: Palo Alto, CA - zip_id: 10019 name: New York, NY + schema: + locations: + zip: + types: + - bsonType: Number + name: + types: + - bsonType: String diff --git a/generator/config/stage/facet.yaml b/generator/config/stage/facet.yaml index 54672dfe5..33dc9cb49 100644 --- a/generator/config/stage/facet.yaml +++ b/generator/config/stage/facet.yaml @@ -42,3 +42,25 @@ tests: - $bucketAuto: groupBy: $year buckets: 4 + schema: + artwork: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + artist: + types: + - bsonType: String + year: + types: + - bsonType: Number + price: + types: + - bsonType: Decimal128 + tags: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/stage/fill.yaml b/generator/config/stage/fill.yaml index c4e686bda..8a0256997 100644 --- a/generator/config/stage/fill.yaml +++ b/generator/config/stage/fill.yaml @@ -48,6 +48,20 @@ tests: value: 0 sneakersSold: value: 0 + schema: + dailySales: + date: + types: + - bsonType: Date + bootsSold: + types: + - bsonType: Number + sandalsSold: + types: + - bsonType: Number + sneakersSold: + types: + - bsonType: Number - 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: @@ -57,6 +71,14 @@ tests: output: price: method: linear + schema: + stock: + time: + types: + - bsonType: Date + price: + types: + - bsonType: Number - 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: @@ -66,6 +88,14 @@ tests: output: score: method: locf + schema: + restaurantReviews: + date: + types: + - bsonType: Date + score: + types: + - bsonType: Number - name: Fill Data for Distinct Partitions link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/#fill-data-for-distinct-partitions pipeline: @@ -77,6 +107,17 @@ tests: output: score: method: locf + schema: + restaurantReviewsMultiple: + date: + types: + - bsonType: Date + restaurant: + types: + - bsonType: String + score: + types: + - bsonType: Number - 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: @@ -92,3 +133,11 @@ tests: output: score: method: locf + schema: + restaurantReviews: + date: + types: + - bsonType: Date + score: + types: + - bsonType: Number diff --git a/generator/config/stage/geoNear.yaml b/generator/config/stage/geoNear.yaml index f32cd47dc..e4f1a53a7 100644 --- a/generator/config/stage/geoNear.yaml +++ b/generator/config/stage/geoNear.yaml @@ -83,6 +83,26 @@ tests: category: Parks includeLocs: dist.location spherical: true + schema: + places: + name: + types: + - bsonType: String + location: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Number + category: + types: + - bsonType: String - name: Minimum Distance link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#minimum-distance pipeline: @@ -98,6 +118,26 @@ tests: category: Parks includeLocs: dist.location spherical: true + schema: + places: + name: + types: + - bsonType: String + location: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Number + category: + types: + - bsonType: String - name: with the let option link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#-geonear-with-the-let-option pipeline: @@ -109,6 +149,26 @@ tests: category: Parks includeLocs: dist.location spherical: true + schema: + places: + name: + types: + - bsonType: String + location: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Number + category: + types: + - bsonType: String - name: with Bound let Option link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/#-geonear-with-bound-let-option pipeline: @@ -123,6 +183,26 @@ tests: as: joinedField - $match: name: Sara D. Roosevelt Park + schema: + places: + name: + types: + - bsonType: String + location: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Number + category: + types: + - bsonType: String - 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: @@ -137,3 +217,31 @@ tests: query: category: Parks - $limit: 5 + schema: + places: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + location: + types: + - bsonType: Document + fields: + type: + types: + - bsonType: String + coordinates: + types: + - bsonType: Array + types: + - bsonType: Number + legacy: + types: + - bsonType: Array + types: + - bsonType: Number + category: + types: + - bsonType: String diff --git a/generator/config/stage/graphLookup.yaml b/generator/config/stage/graphLookup.yaml index 626b1ec39..0d38e8b22 100644 --- a/generator/config/stage/graphLookup.yaml +++ b/generator/config/stage/graphLookup.yaml @@ -62,6 +62,17 @@ tests: connectFromField: reportsTo connectToField: name as: reportingHierarchy + schema: + employees: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + reportsTo: + types: + - bsonType: String - name: Across Multiple Collections link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/#across-multiple-collections pipeline: @@ -73,6 +84,19 @@ tests: maxDepth: 2 depthField: numConnections as: destinations + schema: + airports: + _id: + types: + - bsonType: Number + airport: + types: + - bsonType: String + connects: + types: + - bsonType: Array + types: + - bsonType: String - name: With a Query Filter link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/#with-a-query-filter pipeline: @@ -90,3 +114,21 @@ tests: name: 1 friends: 1 connections who play golf: $golfers.name + schema: + people: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + friends: + types: + - bsonType: Array + types: + - bsonType: String + hobbies: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/stage/group.yaml b/generator/config/stage/group.yaml index 3033ab2ca..501776c44 100644 --- a/generator/config/stage/group.yaml +++ b/generator/config/stage/group.yaml @@ -28,11 +28,45 @@ tests: _id: ~ count: $count: {} + schema: + sales: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Decimal128 + quantity: + types: + - bsonType: Int32 + date: + types: + - bsonType: Date - name: Retrieve Distinct Values link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#retrieve-distinct-values pipeline: - $group: _id: $item + schema: + sales: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Decimal128 + quantity: + types: + - bsonType: Int32 + date: + types: + - bsonType: Date - name: Group by Item Having link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-by-item-having pipeline: @@ -46,6 +80,23 @@ tests: - $match: totalSaleAmount: $gte: 100 + schema: + sales: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Decimal128 + quantity: + types: + - bsonType: Int32 + date: + types: + - bsonType: Date - name: Calculate Count Sum and Average link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#calculate-count--sum--and-average pipeline: @@ -69,6 +120,23 @@ tests: $sum: 1 - $sort: totalSaleAmount: -1 + schema: + sales: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Decimal128 + quantity: + types: + - bsonType: Int32 + date: + types: + - bsonType: Date - name: Group by null link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-by-null pipeline: @@ -83,6 +151,23 @@ tests: $avg: $quantity count: $sum: 1 + schema: + sales: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Decimal128 + quantity: + types: + - bsonType: Int32 + date: + types: + - bsonType: Date - name: Pivot Data link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#pivot-data pipeline: @@ -90,6 +175,20 @@ tests: _id: $author books: $push: $title + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + author: + types: + - bsonType: String + copies: + types: + - bsonType: Number - name: Group Documents by author link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/#group-documents-by-author pipeline: @@ -101,3 +200,20 @@ tests: totalCopies: $sum: - $books.copies + schema: + sales: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Decimal128 + quantity: + types: + - bsonType: Int32 + date: + types: + - bsonType: Date diff --git a/generator/config/stage/indexStats.yaml b/generator/config/stage/indexStats.yaml index 78a4f55df..14bac9c24 100644 --- a/generator/config/stage/indexStats.yaml +++ b/generator/config/stage/indexStats.yaml @@ -11,3 +11,20 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/#example pipeline: - $indexStats: {} + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + quantity: + types: + - bsonType: Number + type: + types: + - bsonType: String diff --git a/generator/config/stage/limit.yaml b/generator/config/stage/limit.yaml index cbb058284..736d197fd 100644 --- a/generator/config/stage/limit.yaml +++ b/generator/config/stage/limit.yaml @@ -15,3 +15,8 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/#example pipeline: - $limit: 5 + schema: + TestCollection: + _id: + types: + - bsonType: ObjectId diff --git a/generator/config/stage/listLocalSessions.yaml b/generator/config/stage/listLocalSessions.yaml index 88b23fa90..6f00eddfa 100644 --- a/generator/config/stage/listLocalSessions.yaml +++ b/generator/config/stage/listLocalSessions.yaml @@ -25,6 +25,11 @@ tests: pipeline: - $listLocalSessions: allUsers: true + schema: + TestCollection: &ref_0 + _id: + types: + - bsonType: ObjectId - 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: @@ -32,7 +37,11 @@ tests: users: - user: myAppReader db: test + schema: + TestCollection: *ref_0 - 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: {} + schema: + TestCollection: *ref_0 diff --git a/generator/config/stage/listSampledQueries.yaml b/generator/config/stage/listSampledQueries.yaml index f64ed8df3..1c1f5e8c5 100644 --- a/generator/config/stage/listSampledQueries.yaml +++ b/generator/config/stage/listSampledQueries.yaml @@ -16,8 +16,15 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/#list-sampled-queries-for-all-collections pipeline: - $listSampledQueries: {} + schema: + TestCollection: &ref_0 + _id: + types: + - bsonType: ObjectId - 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 + schema: + TestCollection: *ref_0 diff --git a/generator/config/stage/listSearchIndexes.yaml b/generator/config/stage/listSearchIndexes.yaml index a53f736e5..aada0e7ce 100644 --- a/generator/config/stage/listSearchIndexes.yaml +++ b/generator/config/stage/listSearchIndexes.yaml @@ -24,13 +24,22 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/#return-all-search-indexes pipeline: - $listSearchIndexes: {} + schema: + TestCollection: &ref_0 + _id: + types: + - bsonType: ObjectId - 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 + schema: + TestCollection: *ref_0 - 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 + schema: + TestCollection: *ref_0 diff --git a/generator/config/stage/listSessions.yaml b/generator/config/stage/listSessions.yaml index 5f020a7ab..7bf658614 100644 --- a/generator/config/stage/listSessions.yaml +++ b/generator/config/stage/listSessions.yaml @@ -25,6 +25,11 @@ tests: pipeline: - $listSessions: allUsers: true + schema: + TestCollection: &ref_0 + _id: + types: + - bsonType: ObjectId - 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: @@ -32,7 +37,11 @@ tests: users: - user: myAppReader db: test + schema: + TestCollection: *ref_0 - 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: {} + schema: + TestCollection: *ref_0 diff --git a/generator/config/stage/lookup.yaml b/generator/config/stage/lookup.yaml index 4e8f76399..2f57c8bff 100644 --- a/generator/config/stage/lookup.yaml +++ b/generator/config/stage/lookup.yaml @@ -55,6 +55,20 @@ tests: localField: item foreignField: sku as: inventory_docs + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + quantity: + types: + - bsonType: Number - name: Use $lookup with an Array link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#use--lookup-with-an-array pipeline: @@ -63,6 +77,24 @@ tests: localField: enrollmentlist foreignField: name as: enrollee_info + schema: + classes: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + enrollmentlist: + types: + - bsonType: Array + types: + - bsonType: String + days: + types: + - bsonType: Array + types: + - bsonType: String - name: Use $lookup with $mergeObjects link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#use--lookup-with--mergeobjects pipeline: @@ -80,6 +112,20 @@ tests: - $$ROOT - $project: fromItems: 0 + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + quantity: + types: + - bsonType: Number - 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: @@ -102,6 +148,7 @@ tests: stock_item: 0 _id: 0 as: stockdata + schema: '// TODO: No schema found in docs' - 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: @@ -118,6 +165,20 @@ tests: - $replaceRoot: newRoot: $date as: holidays + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + quantity: + types: + - bsonType: Number - 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: @@ -134,3 +195,21 @@ tests: - $$orders_drink - $beverages as: matches + schema: + restaurants: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + food: + types: + - bsonType: Array + types: + - bsonType: String + beverages: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/stage/match.yaml b/generator/config/stage/match.yaml index 417f88995..27454c6a3 100644 --- a/generator/config/stage/match.yaml +++ b/generator/config/stage/match.yaml @@ -16,6 +16,20 @@ tests: pipeline: - $match: author: dave + schema: + TestCollection: + _id: + types: + - bsonType: ObjectId + author: + types: + - bsonType: String + score: + types: + - bsonType: Number + views: + types: + - bsonType: Number - name: Perform a Count link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/#perform-a-count pipeline: @@ -30,3 +44,17 @@ tests: _id: ~ count: $sum: 1 + schema: + TestCollection: + _id: + types: + - bsonType: ObjectId + author: + types: + - bsonType: String + score: + types: + - bsonType: Number + views: + types: + - bsonType: Number diff --git a/generator/config/stage/merge.yaml b/generator/config/stage/merge.yaml index ecba8f381..705a8f45e 100644 --- a/generator/config/stage/merge.yaml +++ b/generator/config/stage/merge.yaml @@ -57,6 +57,23 @@ tests: on: _id whenMatched: replace whenNotMatched: insert + schema: + salaries: + _id: + types: + - bsonType: Number + employee: + types: + - bsonType: String + dept: + types: + - bsonType: String + salary: + types: + - bsonType: Number + fiscal_year: + types: + - bsonType: Number - 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: @@ -76,6 +93,23 @@ tests: on: _id whenMatched: replace whenNotMatched: insert + schema: + salaries: + _id: + types: + - bsonType: Number + employee: + types: + - bsonType: String + dept: + types: + - bsonType: String + salary: + types: + - bsonType: Number + fiscal_year: + types: + - bsonType: Number - name: Only Insert New Data link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#only-insert-new-data pipeline: @@ -100,6 +134,23 @@ tests: - dept - fiscal_year whenMatched: fail + schema: + salaries: + _id: + types: + - bsonType: Number + employee: + types: + - bsonType: String + dept: + types: + - bsonType: String + salary: + types: + - bsonType: Number + fiscal_year: + types: + - bsonType: Number - name: Merge Results from Multiple Collections link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#merge-results-from-multiple-collections pipeline: @@ -112,6 +163,23 @@ tests: on: _id whenMatched: merge whenNotMatched: insert + schema: + purchaseorders: + _id: + types: + - bsonType: Number + quarter: + types: + - bsonType: String + region: + types: + - bsonType: String + qty: + types: + - bsonType: Number + reportDate: + types: + - bsonType: Date - 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: @@ -140,6 +208,17 @@ tests: - $thumbsdown - $$new.thumbsdown whenNotMatched: insert + schema: + votes: + date: + types: + - bsonType: Date + thumbsup: + types: + - bsonType: Number + thumbsdown: + types: + - bsonType: Number - 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: @@ -150,3 +229,20 @@ tests: whenMatched: - $addFields: salesYear: $$year + schema: + salaries: + _id: + types: + - bsonType: Number + employee: + types: + - bsonType: String + dept: + types: + - bsonType: String + salary: + types: + - bsonType: Number + fiscal_year: + types: + - bsonType: Number diff --git a/generator/config/stage/out.yaml b/generator/config/stage/out.yaml index 3dfc4e6ea..cb9301906 100644 --- a/generator/config/stage/out.yaml +++ b/generator/config/stage/out.yaml @@ -22,6 +22,20 @@ tests: books: $push: $title - $out: authors + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + author: + types: + - bsonType: String + copies: + types: + - bsonType: Number - name: Output to a Different Database link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/#output-to-a-different-database pipeline: @@ -32,3 +46,17 @@ tests: - $out: db: reporting coll: authors + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + author: + types: + - bsonType: String + copies: + types: + - bsonType: Number diff --git a/generator/config/stage/planCacheStats.yaml b/generator/config/stage/planCacheStats.yaml index e6c07c7de..2dff1a55e 100644 --- a/generator/config/stage/planCacheStats.yaml +++ b/generator/config/stage/planCacheStats.yaml @@ -11,9 +11,43 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/#return-information-for-all-entries-in-the-query-cache pipeline: - $planCacheStats: {} + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Decimal128 + quantity: + types: + - bsonType: Number + type: + types: + - bsonType: String - 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 + schema: + orders: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Decimal128 + quantity: + types: + - bsonType: Number + type: + types: + - bsonType: String diff --git a/generator/config/stage/project.yaml b/generator/config/stage/project.yaml index da9803c2a..b653301c9 100644 --- a/generator/config/stage/project.yaml +++ b/generator/config/stage/project.yaml @@ -18,6 +18,30 @@ tests: - $project: title: 1 author: 1 + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + isbn: + types: + - bsonType: String + author: + types: + - bsonType: Document + fields: + last: + types: + - bsonType: String + first: + types: + - bsonType: String + copies: + types: + - bsonType: Number - 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: @@ -25,11 +49,62 @@ tests: _id: 0 title: 1 author: 1 + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + isbn: + types: + - bsonType: String + author: + types: + - bsonType: Document + fields: + last: + types: + - bsonType: String + first: + types: + - bsonType: String + copies: + types: + - bsonType: Number - 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 + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + isbn: + types: + - bsonType: String + author: + types: + - bsonType: Document + fields: + last: + types: + - bsonType: String + first: + types: + - bsonType: String + copies: + types: + - bsonType: Number + lastModified: + types: + - bsonType: String - name: Exclude Fields from Embedded Documents link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#exclude-fields-from-embedded-documents pipeline: @@ -40,6 +115,33 @@ tests: author: first: 0 lastModified: 0 + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + isbn: + types: + - bsonType: String + author: + types: + - bsonType: Document + fields: + last: + types: + - bsonType: String + first: + types: + - bsonType: String + copies: + types: + - bsonType: Number + lastModified: + types: + - bsonType: String - name: Conditionally Exclude Fields link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#conditionally-exclude-fields pipeline: @@ -55,6 +157,36 @@ tests: - $author.middle then: $$REMOVE else: $author.middle + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + isbn: + types: + - bsonType: String + author: + types: + - bsonType: Document + fields: + last: + types: + - bsonType: String + first: + types: + - bsonType: String + middle: + types: + - bsonType: String + copies: + types: + - bsonType: Number + lastModified: + types: + - bsonType: String - 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: @@ -63,6 +195,40 @@ tests: - $project: stop: title: 1 + schema: + bookmarks: + _id: + types: + - bsonType: Number + user: + types: + - bsonType: String + stop: + types: + - bsonType: Document + fields: + title: + types: + - bsonType: String + author: + types: + - bsonType: String + page: + types: + - bsonType: Number + - bsonType: Array + types: + - bsonType: Document + fields: + title: + types: + - bsonType: String + author: + types: + - bsonType: String + page: + types: + - bsonType: Number - name: Include Computed Fields link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#include-computed-fields pipeline: @@ -96,6 +262,30 @@ tests: - 1 lastName: $author.last copiesSold: $copies + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + isbn: + types: + - bsonType: String + author: + types: + - bsonType: Document + fields: + last: + types: + - bsonType: String + first: + types: + - bsonType: String + copies: + types: + - bsonType: Number - name: Project New Array Fields link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#project-new-array-fields pipeline: @@ -103,3 +293,14 @@ tests: myArray: - $x - $y + schema: + TestCollection: + _id: + types: + - bsonType: ObjectId + x: + types: + - bsonType: Number + y: + types: + - bsonType: Number diff --git a/generator/config/stage/redact.yaml b/generator/config/stage/redact.yaml index 56c81b919..453850a38 100644 --- a/generator/config/stage/redact.yaml +++ b/generator/config/stage/redact.yaml @@ -28,6 +28,49 @@ tests: - 0 then: $$DESCEND else: $$PRUNE + schema: + TestCollection: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + tags: + types: + - bsonType: Array + types: + - bsonType: String + year: + types: + - bsonType: Number + subsections: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + subtitle: + types: + - bsonType: String + tags: + types: + - bsonType: Array + types: + - bsonType: String + content: + types: + - bsonType: String + - bsonType: Document + fields: + text: + types: + - bsonType: String + tags: + types: + - bsonType: Array + types: + - bsonType: String - 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: @@ -41,3 +84,46 @@ tests: - 5 then: $$PRUNE else: $$DESCEND + schema: + TestCollection: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + tags: + types: + - bsonType: Array + types: + - bsonType: String + year: + types: + - bsonType: Number + subsections: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + subtitle: + types: + - bsonType: String + tags: + types: + - bsonType: Array + types: + - bsonType: String + content: + types: + - bsonType: String + - bsonType: Document + fields: + text: + types: + - bsonType: String + tags: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/stage/replaceRoot.yaml b/generator/config/stage/replaceRoot.yaml index dc627c311..e0e6ac83e 100644 --- a/generator/config/stage/replaceRoot.yaml +++ b/generator/config/stage/replaceRoot.yaml @@ -22,6 +22,30 @@ tests: birds: 0 fish: 0 - $pets + schema: + TestCollection: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + age: + types: + - bsonType: Number + pets: + types: + - bsonType: Document + fields: + dogs: + types: + - bsonType: Number + cats: + types: + - bsonType: Number + fish: + types: + - bsonType: Number - 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: @@ -32,6 +56,29 @@ tests: $gte: 90 - $replaceRoot: newRoot: $grades + schema: + students: + _id: + types: + - bsonType: Number + grades: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + test: + types: + - bsonType: Number + grade: + types: + - bsonType: Number + mean: + types: + - bsonType: Number + std: + types: + - bsonType: Number - name: with a newly created document link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/#-replaceroot-with-a-newly-created-document pipeline: @@ -42,6 +89,20 @@ tests: - $first_name - ' ' - $last_name + schema: + TestCollection: + _id: + types: + - bsonType: Number + first_name: + types: + - bsonType: String + last_name: + types: + - bsonType: String + city: + types: + - bsonType: String - 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: @@ -54,3 +115,20 @@ tests: cell: '' home: '' - $$ROOT + schema: + contacts: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + email: + types: + - bsonType: String + cell: + types: + - bsonType: String + home: + types: + - bsonType: String diff --git a/generator/config/stage/replaceWith.yaml b/generator/config/stage/replaceWith.yaml index e14ab6d3c..1acb3805c 100644 --- a/generator/config/stage/replaceWith.yaml +++ b/generator/config/stage/replaceWith.yaml @@ -22,6 +22,30 @@ tests: birds: 0 fish: 0 - $pets + schema: + people: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + age: + types: + - bsonType: Number + pets: + types: + - bsonType: Document + fields: + dogs: + types: + - bsonType: Number + cats: + types: + - bsonType: Number + fish: + types: + - bsonType: Number - 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: @@ -31,6 +55,29 @@ tests: grades.grade: $gte: 90 - $replaceWith: $grades + schema: + students: + _id: + types: + - bsonType: Number + grades: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + test: + types: + - bsonType: Number + grade: + types: + - bsonType: Number + mean: + types: + - bsonType: Number + std: + types: + - bsonType: Number - name: a Newly Created Document link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/#-replacewith-a-newly-created-document pipeline: @@ -45,6 +92,26 @@ tests: - $quantity status: Complete asofDate: $$NOW + schema: + sales: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Number + quantity: + types: + - bsonType: Number + date: + types: + - bsonType: Date + status: + types: + - bsonType: String - 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: @@ -56,3 +123,17 @@ tests: cell: '' home: '' - $$ROOT + schema: + contacts: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + email: + types: + - bsonType: String + cell: + types: + - bsonType: String diff --git a/generator/config/stage/sample.yaml b/generator/config/stage/sample.yaml index 45efca026..0680f81dd 100644 --- a/generator/config/stage/sample.yaml +++ b/generator/config/stage/sample.yaml @@ -14,7 +14,21 @@ arguments: The number of documents to randomly select. tests: - name: Example - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/#example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/#examples pipeline: - $sample: size: 3 + schema: + users: + _id: + types: + - bsonType: Number + name: + types: + - bsonType: String + q1: + types: + - bsonType: Boolean + q2: + types: + - bsonType: Boolean diff --git a/generator/config/stage/search.yaml b/generator/config/stage/search.yaml index 359a60365..e1d41f22a 100644 --- a/generator/config/stage/search.yaml +++ b/generator/config/stage/search.yaml @@ -33,7 +33,7 @@ arguments: - bool description: | Parallelize search across segments on dedicated search nodes. - If you don't have separate search nodes on your cluster, + If you don't have separate search nodes on your cluster, Atlas Search ignores this flag. If omitted, defaults to false. - name: count optional: true @@ -79,7 +79,7 @@ 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 + link: https://www.mongodb.com/docs/atlas/atlas-search/aggregation-stages/search/#aggregation-variable pipeline: - $search: near: @@ -96,6 +96,143 @@ tests: meta: - $replaceWith: $$SEARCH_META - $limit: 1 + schema: + movies: &ref_0 + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String - name: Date Search and Sort link: https://www.mongodb.com/docs/atlas/atlas-search/sort/#date-search-and-sort pipeline: @@ -111,6 +248,8 @@ tests: _id: 0 title: 1 released: 1 + schema: + movies: *ref_0 - name: Number Search and Sort link: https://www.mongodb.com/docs/atlas/atlas-search/sort/#number-search-and-sort pipeline: @@ -125,6 +264,8 @@ tests: _id: 0 title: 1 awards.wins: 1 + schema: + movies: *ref_0 - name: Sort by score link: https://www.mongodb.com/docs/atlas/atlas-search/sort/#sort-by-score pipeline: @@ -142,6 +283,8 @@ tests: title: 1 score: $meta: searchScore + schema: + movies: *ref_0 - name: Paginate results after a token link: https://www.mongodb.com/docs/atlas/atlas-search/paginate-results/#search-after-the-reference-point pipeline: @@ -154,6 +297,8 @@ tests: $meta: searchScore released: 1 searchAfter: CMtJGgYQuq+ngwgaCSkAjBYH7AAAAA== + schema: + movies: *ref_0 - name: Paginate results before a token link: https://www.mongodb.com/docs/atlas/atlas-search/paginate-results/#search-before-the-reference-point pipeline: @@ -166,6 +311,8 @@ tests: $meta: searchScore released: 1 searchBefore: CJ6kARoGELqvp4MIGgkpACDA3U8BAAA= + schema: + movies: *ref_0 - name: Count results link: https://www.mongodb.com/docs/atlas/atlas-search/counting/#count-results pipeline: @@ -181,6 +328,8 @@ tests: title: 1 released: 1 - $limit: 2 + schema: + movies: *ref_0 - name: Track Search terms link: https://www.mongodb.com/docs/atlas/atlas-search/tracking/#examples pipeline: @@ -194,6 +343,8 @@ tests: - $project: _id: 0 title: 1 + schema: + movies: *ref_0 - name: Return Stored Source Fields link: https://www.mongodb.com/docs/atlas/atlas-search/return-stored-source/#examples pipeline: @@ -213,3 +364,5 @@ tests: localField: _id foreignField: _id as: document + schema: + movies: *ref_0 diff --git a/generator/config/stage/searchMeta.yaml b/generator/config/stage/searchMeta.yaml index 53c09e6c1..51a68cced 100644 --- a/generator/config/stage/searchMeta.yaml +++ b/generator/config/stage/searchMeta.yaml @@ -29,7 +29,7 @@ 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 + link: https://www.mongodb.com/docs/atlas/atlas-search/aggregation-stages/searchMeta/#example pipeline: - $searchMeta: range: @@ -38,6 +38,143 @@ tests: lt: 1999 count: type: total + schema: + movies: &ref_0 + _id: + types: + - bsonType: Document + fields: + $oid: + types: + - bsonType: String + title: + types: + - bsonType: String + year: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + runtime: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + released: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + poster: + types: + - bsonType: String + plot: + types: + - bsonType: String + fullplot: + types: + - bsonType: String + lastupdated: + types: + - bsonType: String + type: + types: + - bsonType: String + directors: + types: + - bsonType: Array + types: + - bsonType: String + imdb: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + votes: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + id: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + cast: + types: + - bsonType: Array + types: + - bsonType: String + countries: + types: + - bsonType: Array + types: + - bsonType: String + genres: + types: + - bsonType: Array + types: + - bsonType: String + tomatoes: + types: + - bsonType: Document + fields: + viewer: + types: + - bsonType: Document + fields: + rating: + types: + - bsonType: Document + fields: + $numberDouble: + types: + - bsonType: String + numReviews: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String + lastUpdated: + types: + - bsonType: Document + fields: + $date: + types: + - bsonType: Document + fields: + $numberLong: + types: + - bsonType: String + num_mflix_comments: + types: + - bsonType: Document + fields: + $numberInt: + types: + - bsonType: String - name: Year Facet link: https://www.mongodb.com/docs/atlas/atlas-search/facet/#example-1 pipeline: @@ -57,6 +194,8 @@ tests: - 1990 - 2000 default: other + schema: + movies: *ref_0 - name: Date Facet link: https://www.mongodb.com/docs/atlas/atlas-search/facet/#example-2 pipeline: @@ -77,6 +216,8 @@ tests: - !bson_utcdatetime '2010-01-01T00:00:00.000Z' - !bson_utcdatetime '2015-01-01T00:00:00.000Z' default: other + schema: + movies: *ref_0 - name: Metadata Results link: https://www.mongodb.com/docs/atlas/atlas-search/facet/#examples pipeline: @@ -100,6 +241,8 @@ tests: - 2005 - 2010 - 2015 + schema: + movies: *ref_0 - name: Autocomplete Bucket Results through Facet Queries link: https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#bucket-results-through-facet-queries pipeline: @@ -113,3 +256,5 @@ tests: titleFacet: type: string path: title + schema: + movies: *ref_0 diff --git a/generator/config/stage/set.yaml b/generator/config/stage/set.yaml index d77daa841..ef514ba1e 100644 --- a/generator/config/stage/set.yaml +++ b/generator/config/stage/set.yaml @@ -29,16 +29,66 @@ tests: - $totalHomework - $totalQuiz - $extraCredit + schema: + scores: + _id: + types: + - bsonType: Number + student: + types: + - bsonType: String + homework: + types: + - bsonType: Array + types: + - bsonType: Number + quiz: + types: + - bsonType: Array + types: + - bsonType: Number + extraCredit: + types: + - bsonType: Number - 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 + schema: + vehicles: + _id: + types: + - bsonType: Number + type: + types: + - bsonType: String + specs: + types: + - bsonType: Document + fields: + doors: + types: + - bsonType: Number + wheels: + types: + - bsonType: Number - name: Overwriting an existing field link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#overwriting-an-existing-field pipeline: - $set: cats: 20 + schema: + animals: + _id: + types: + - bsonType: Number + dogs: + types: + - bsonType: Number + cats: + types: + - bsonType: Number - name: Add Element to an Array link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/#add-element-to-an-array pipeline: @@ -49,6 +99,27 @@ tests: $concatArrays: - $homework - - 7 + schema: + scores: + _id: + types: + - bsonType: Number + student: + types: + - bsonType: String + homework: + types: + - bsonType: Array + types: + - bsonType: Number + quiz: + types: + - bsonType: Array + types: + - bsonType: Number + extraCredit: + types: + - bsonType: Number - 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: @@ -56,3 +127,24 @@ tests: quizAverage: $avg: - $quiz + schema: + scores: + _id: + types: + - bsonType: Number + student: + types: + - bsonType: String + homework: + types: + - bsonType: Array + types: + - bsonType: Number + quiz: + types: + - bsonType: Array + types: + - bsonType: Number + extraCredit: + types: + - bsonType: Number diff --git a/generator/config/stage/setWindowFields.yaml b/generator/config/stage/setWindowFields.yaml index 168ba8e25..e31c4135f 100644 --- a/generator/config/stage/setWindowFields.yaml +++ b/generator/config/stage/setWindowFields.yaml @@ -40,6 +40,26 @@ tests: 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 - 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: @@ -56,6 +76,26 @@ tests: 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 - 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: @@ -72,6 +112,26 @@ tests: documents: - -1 - 0 + 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 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 @@ -95,6 +155,26 @@ tests: documents: - unbounded - 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 - name: Range Window Example link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/#range-window-example pipeline: @@ -109,6 +189,26 @@ tests: range: - -10 - 10 + 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 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: @@ -124,6 +224,26 @@ tests: - unbounded - 10 unit: month + 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 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: @@ -139,3 +259,23 @@ tests: - unbounded - -10 unit: month + 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/stage/shardedDataDistribution.yaml b/generator/config/stage/shardedDataDistribution.yaml index 41cf0828d..87864231e 100644 --- a/generator/config/stage/shardedDataDistribution.yaml +++ b/generator/config/stage/shardedDataDistribution.yaml @@ -12,3 +12,8 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/shardedDataDistribution/#examples pipeline: - $shardedDataDistribution: {} + schema: + TestCollection: + _id: + types: + - bsonType: ObjectId diff --git a/generator/config/stage/skip.yaml b/generator/config/stage/skip.yaml index cf1f9f43a..cb9ad7c50 100644 --- a/generator/config/stage/skip.yaml +++ b/generator/config/stage/skip.yaml @@ -12,6 +12,11 @@ arguments: - int tests: - name: Example - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/#example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/#examples pipeline: - $skip: 5 + schema: + TestCollection: + _id: + types: + - bsonType: ObjectId diff --git a/generator/config/stage/sort.yaml b/generator/config/stage/sort.yaml index 54923075c..be4776c6d 100644 --- a/generator/config/stage/sort.yaml +++ b/generator/config/stage/sort.yaml @@ -19,6 +19,17 @@ tests: - $sort: age: -1 posts: 1 + schema: + users: &ref_0 + age: + types: + - bsonType: Int32 + posts: + types: + - bsonType: Int32 + name: + types: + - bsonType: String - name: Text Score Metadata Sort link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/#text-score-metadata-sort pipeline: @@ -29,3 +40,5 @@ tests: score: $meta: textScore posts: -1 + schema: + users: *ref_0 diff --git a/generator/config/stage/sortByCount.yaml b/generator/config/stage/sortByCount.yaml index dae89bf33..5565fa550 100644 --- a/generator/config/stage/sortByCount.yaml +++ b/generator/config/stage/sortByCount.yaml @@ -12,8 +12,27 @@ arguments: - expression tests: - name: Example - link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/#example + link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/#examples pipeline: - $unwind: path: $tags - $sortByCount: $tags + schema: + exhibits: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + artist: + types: + - bsonType: String + year: + types: + - bsonType: Number + tags: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/stage/unionWith.yaml b/generator/config/stage/unionWith.yaml index 3cd3ae5db..722b8c843 100644 --- a/generator/config/stage/unionWith.yaml +++ b/generator/config/stage/unionWith.yaml @@ -45,6 +45,17 @@ tests: _id: 1 store: 1 item: 1 + schema: + sales_2017: + store: + types: + - bsonType: String + item: + types: + - bsonType: String + quantity: + types: + - bsonType: Number - 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: @@ -60,3 +71,14 @@ tests: $sum: $quantity - $sort: total: -1 + schema: + sales_2017: + store: + types: + - bsonType: String + item: + types: + - bsonType: String + quantity: + types: + - bsonType: Number diff --git a/generator/config/stage/unset.yaml b/generator/config/stage/unset.yaml index 141ffd625..be03479da 100644 --- a/generator/config/stage/unset.yaml +++ b/generator/config/stage/unset.yaml @@ -18,12 +18,78 @@ tests: pipeline: - $unset: - copies + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + isbn: + types: + - bsonType: String + author: + types: + - bsonType: Document + fields: + last: + types: + - bsonType: String + first: + types: + - bsonType: String + copies: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + warehouse: + types: + - bsonType: String + qty: + types: + - bsonType: Number - name: Remove Top-Level Fields link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/#remove-top-level-fields pipeline: - $unset: - isbn - copies + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + isbn: + types: + - bsonType: String + author: + types: + - bsonType: Document + fields: + last: + types: + - bsonType: String + first: + types: + - bsonType: String + copies: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + warehouse: + types: + - bsonType: String + qty: + types: + - bsonType: Number - name: Remove Embedded Fields link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/#remove-embedded-fields pipeline: @@ -31,3 +97,36 @@ tests: - isbn - author.first - copies.warehouse + schema: + books: + _id: + types: + - bsonType: Number + title: + types: + - bsonType: String + isbn: + types: + - bsonType: String + author: + types: + - bsonType: Document + fields: + last: + types: + - bsonType: String + first: + types: + - bsonType: String + copies: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + warehouse: + types: + - bsonType: String + qty: + types: + - bsonType: Number diff --git a/generator/config/stage/unwind.yaml b/generator/config/stage/unwind.yaml index 6c6641479..ecad4b6fc 100644 --- a/generator/config/stage/unwind.yaml +++ b/generator/config/stage/unwind.yaml @@ -32,18 +32,57 @@ tests: pipeline: - $unwind: path: $sizes + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + sizes: + types: + - bsonType: Array + types: + - bsonType: String - name: preserveNullAndEmptyArrays link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#preservenullandemptyarrays pipeline: - $unwind: path: $sizes preserveNullAndEmptyArrays: true + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + sizes: + types: + - bsonType: Array + types: + - bsonType: String - name: includeArrayIndex link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#includearrayindex pipeline: - $unwind: path: $sizes includeArrayIndex: arrayIndex + schema: + inventory: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + sizes: + types: + - bsonType: Array + types: + - bsonType: String - name: Group by Unwound Values link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#group-by-unwound-values pipeline: @@ -56,6 +95,24 @@ tests: $avg: $price - $sort: averagePrice: -1 + schema: + inventory2: + _id: + types: + - bsonType: Number + item: + types: + - bsonType: String + price: + types: + - bsonType: Decimal128 + sizes: + types: + - bsonType: Array + types: + - bsonType: String + - bsonType: String + - bsonType: 'Null' - name: Unwind Embedded Arrays link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#unwind-embedded-arrays pipeline: @@ -70,3 +127,28 @@ tests: $multiply: - $items.price - $items.quantity + schema: + sales: + _id: + types: + - bsonType: String + items: + types: + - bsonType: Array + types: + - bsonType: Document + fields: + name: + types: + - bsonType: String + tags: + types: + - bsonType: Array + types: + - bsonType: String + price: + types: + - bsonType: Decimal128 + quantity: + types: + - bsonType: Int32 diff --git a/generator/config/stage/vectorSearch.yaml b/generator/config/stage/vectorSearch.yaml index 51e3e4ed4..a5d1a4e63 100644 --- a/generator/config/stage/vectorSearch.yaml +++ b/generator/config/stage/vectorSearch.yaml @@ -65,6 +65,17 @@ tests: title: 1 score: $meta: vectorSearchScore + schema: + TestCollection: + plot: + types: + - bsonType: String + title: + types: + - bsonType: String + score: + types: + - bsonType: Number - name: ANN Filter link: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#ann-examples pipeline: @@ -88,8 +99,19 @@ tests: year: 1 score: $meta: vectorSearchScore + schema: + TestCollection: + plot: + types: + - bsonType: String + title: + types: + - bsonType: String + score: + types: + - bsonType: Number - name: ENN - link: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#enn-examples + link: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#enn-example pipeline: - $vectorSearch: index: vector_index @@ -106,3 +128,14 @@ tests: title: 1 score: $meta: vectorSearchScore + schema: + TestCollection: + plot: + types: + - bsonType: String + title: + types: + - bsonType: String + score: + types: + - bsonType: Number From cc2c832e8e82898c30190f97de48f3bef9544285 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Mon, 26 May 2025 13:15:36 +0200 Subject: [PATCH 11/16] Update with some refs --- generator/config/query/and.yaml | 20 ++++++++-------- generator/config/query/exists.yaml | 6 +++++ generator/config/query/expr.yaml | 12 +++++----- generator/config/query/geoIntersects.yaml | 20 ++-------------- generator/config/query/geoWithin.yaml | 28 ++++------------------- generator/config/query/nor.yaml | 25 ++++---------------- generator/config/query/not.yaml | 14 +++--------- generator/config/query/or.yaml | 1 + generator/config/query/sampleRate.yaml | 2 +- generator/config/query/size.yaml | 1 + generator/config/query/type.yaml | 10 +++----- 11 files changed, 40 insertions(+), 99 deletions(-) diff --git a/generator/config/query/and.yaml b/generator/config/query/and.yaml index 8db9f894b..f41441507 100644 --- a/generator/config/query/and.yaml +++ b/generator/config/query/and.yaml @@ -23,10 +23,17 @@ tests: - price: $exists: true schema: - inventory: + inventory: &ref_0 price: types: - bsonType: Double + qty: + types: + - bsonType: Int32 + - bsonType: Undefined + sale: + types: + - bsonType: Boolean - 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: @@ -42,13 +49,4 @@ tests: - price: $lt: 5 schema: - inventory: - price: - types: - - bsonType: Double - qty: - types: - - bsonType: Int32 - sale: - types: - - bsonType: Boolean + inventory: *ref_0 diff --git a/generator/config/query/exists.yaml b/generator/config/query/exists.yaml index 52febc113..f950ccf5a 100644 --- a/generator/config/query/exists.yaml +++ b/generator/config/query/exists.yaml @@ -23,10 +23,16 @@ tests: - 15 schema: inventory: + price: + types: + - bsonType: Double qty: types: - bsonType: Int32 - bsonType: Undefined + sale: + types: + - bsonType: Boolean - name: Null Values link: https://www.mongodb.com/docs/manual/reference/operator/query/exists/#null-values pipeline: diff --git a/generator/config/query/expr.yaml b/generator/config/query/expr.yaml index 7cf0199e7..4484698fe 100644 --- a/generator/config/query/expr.yaml +++ b/generator/config/query/expr.yaml @@ -54,16 +54,16 @@ tests: - 0.75 - 5 schema: - monthlyBudget: + supplies: _id: types: - bsonType: Number - category: + item: types: - bsonType: String - budget: + qty: types: - - bsonType: Number - spent: + - bsonType: Int32 + price: types: - - bsonType: Number + - bsonType: Decimal128 diff --git a/generator/config/query/geoIntersects.yaml b/generator/config/query/geoIntersects.yaml index c46c8dac6..01adb3226 100644 --- a/generator/config/query/geoIntersects.yaml +++ b/generator/config/query/geoIntersects.yaml @@ -30,7 +30,7 @@ tests: - - 0 - 0 schema: - places: + places: &ref_0 loc: types: - bsonType: Document @@ -73,20 +73,4 @@ tests: properties: name: urn:x-mongodb:crs:strictwinding:EPSG:4326 schema: - places: - loc: - types: - - bsonType: Document - fields: - type: - types: - - bsonType: String - coordinates: - types: - - bsonType: Array - types: - - bsonType: Array - types: - - bsonType: Array - types: - - bsonType: Double + places: *ref_0 diff --git a/generator/config/query/geoWithin.yaml b/generator/config/query/geoWithin.yaml index 7b439c94c..5611d681f 100644 --- a/generator/config/query/geoWithin.yaml +++ b/generator/config/query/geoWithin.yaml @@ -30,8 +30,8 @@ tests: - - 0 - 0 schema: - places: - loc: + places: &ref_0 + location: types: - bsonType: Document fields: @@ -42,11 +42,7 @@ tests: types: - bsonType: Array types: - - bsonType: Array - types: - - bsonType: Array - types: - - bsonType: Double + - bsonType: Double - name: Within a Big Polygon link: https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/#within-a--big--polygon pipeline: @@ -73,20 +69,4 @@ tests: properties: name: urn:x-mongodb:crs:strictwinding:EPSG:4326 schema: - places: - loc: - types: - - bsonType: Document - fields: - type: - types: - - bsonType: String - coordinates: - types: - - bsonType: Array - types: - - bsonType: Array - types: - - bsonType: Array - types: - - bsonType: Double + places: *ref_0 diff --git a/generator/config/query/nor.yaml b/generator/config/query/nor.yaml index e4fa857ca..cdfeb9d5d 100644 --- a/generator/config/query/nor.yaml +++ b/generator/config/query/nor.yaml @@ -21,13 +21,14 @@ tests: - price: 1.99 - sale: true schema: - inventory: + inventory: &ref_0 price: types: - bsonType: Double qty: types: - bsonType: Int32 + - bsonType: Undefined sale: types: - bsonType: Boolean @@ -41,16 +42,7 @@ tests: $lt: 20 - sale: true schema: - inventory: - price: - types: - - bsonType: Double - qty: - types: - - bsonType: Int32 - sale: - types: - - bsonType: Boolean + inventory: *ref_0 - name: $nor and $exists link: https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and--exists pipeline: @@ -63,13 +55,4 @@ tests: - sale: $exists: false schema: - inventory: - price: - types: - - bsonType: Double - qty: - types: - - bsonType: Int32 - sale: - types: - - bsonType: Boolean + inventory: *ref_0 diff --git a/generator/config/query/not.yaml b/generator/config/query/not.yaml index 930daf725..cb4ebe62a 100644 --- a/generator/config/query/not.yaml +++ b/generator/config/query/not.yaml @@ -19,13 +19,14 @@ tests: $not: $gt: 1.99 schema: - inventory: + inventory: &ref_0 price: types: - bsonType: Double qty: types: - bsonType: Int32 + - bsonType: Undefined sale: types: - bsonType: Boolean @@ -36,13 +37,4 @@ tests: price: $not: !bson_regex ^p.* schema: - inventory: - price: - types: - - bsonType: Double - qty: - types: - - bsonType: Int32 - sale: - types: - - bsonType: Boolean + inventory: *ref_0 diff --git a/generator/config/query/or.yaml b/generator/config/query/or.yaml index b1bfca02e..69b9d627d 100644 --- a/generator/config/query/or.yaml +++ b/generator/config/query/or.yaml @@ -29,6 +29,7 @@ tests: qty: types: - bsonType: Int32 + - bsonType: Undefined sale: types: - bsonType: Boolean diff --git a/generator/config/query/sampleRate.yaml b/generator/config/query/sampleRate.yaml index 125e12d33..950b9217c 100644 --- a/generator/config/query/sampleRate.yaml +++ b/generator/config/query/sampleRate.yaml @@ -21,7 +21,7 @@ tests: $sampleRate: 0.33 - $count: numMatches schema: - collection: + TestCollection: _id: types: - bsonType: ObjectId diff --git a/generator/config/query/size.yaml b/generator/config/query/size.yaml index cb53048f0..16caa841c 100644 --- a/generator/config/query/size.yaml +++ b/generator/config/query/size.yaml @@ -25,6 +25,7 @@ tests: qty: types: - bsonType: Int32 + - bsonType: Undefined sale: types: - bsonType: Boolean diff --git a/generator/config/query/type.yaml b/generator/config/query/type.yaml index 14f3bc656..26a1cec65 100644 --- a/generator/config/query/type.yaml +++ b/generator/config/query/type.yaml @@ -67,22 +67,18 @@ tests: - string - double schema: - addressBook: + grades: _id: types: - bsonType: Number - address: + name: types: - bsonType: String - zipCode: + classAverage: types: - bsonType: String - bsonType: Number - - bsonType: Long - bsonType: Int32 - - bsonType: Array - types: - - bsonType: String - name: Querying by MinKey and MaxKey link: https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-minkey-and-maxkey pipeline: From c027132ee06556598a03496908ee29a11d7a6398 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Mon, 26 May 2025 19:11:17 +0200 Subject: [PATCH 12/16] type tweaks --- generator/config/accumulator/lastN.yaml | 2 +- generator/config/expression/avg.yaml | 6 ++---- generator/config/expression/dateAdd.yaml | 3 +++ generator/config/expression/let.yaml | 2 +- generator/config/expression/reduce.yaml | 8 ++++++++ generator/config/schema.json | 21 +++++++++++++++++++++ generator/config/stage/group.yaml | 1 + generator/config/stage/unset.yaml | 2 +- 8 files changed, 38 insertions(+), 7 deletions(-) diff --git a/generator/config/accumulator/lastN.yaml b/generator/config/accumulator/lastN.yaml index 8beccf112..85e5c4124 100644 --- a/generator/config/accumulator/lastN.yaml +++ b/generator/config/accumulator/lastN.yaml @@ -12,7 +12,7 @@ description: | arguments: - name: input type: - - resolvesToArray + - expression description: | An expression that resolves to the array from which to return n elements. - name: n diff --git a/generator/config/expression/avg.yaml b/generator/config/expression/avg.yaml index 718b94ff1..a81686101 100644 --- a/generator/config/expression/avg.yaml +++ b/generator/config/expression/avg.yaml @@ -18,11 +18,9 @@ tests: pipeline: - $project: quizAvg: - $avg: - - $quizzes + $avg: $quizzes labAvg: - $avg: - - $labs + $avg: $labs examAvg: $avg: - $final diff --git a/generator/config/expression/dateAdd.yaml b/generator/config/expression/dateAdd.yaml index 224def6ec..5ab2d5a42 100644 --- a/generator/config/expression/dateAdd.yaml +++ b/generator/config/expression/dateAdd.yaml @@ -79,6 +79,9 @@ tests: purchaseDate: types: - bsonType: Date + deliveryDate: + 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 pipeline: diff --git a/generator/config/expression/let.yaml b/generator/config/expression/let.yaml index 5d7ca6993..be170126e 100644 --- a/generator/config/expression/let.yaml +++ b/generator/config/expression/let.yaml @@ -10,7 +10,7 @@ description: | arguments: - name: vars type: - - object + - expressionMap 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. diff --git a/generator/config/expression/reduce.yaml b/generator/config/expression/reduce.yaml index 3a20500d4..d77a7afd3 100644 --- a/generator/config/expression/reduce.yaml +++ b/generator/config/expression/reduce.yaml @@ -22,6 +22,14 @@ arguments: - name: in type: - expression + - expressionMap + syntheticVariables: + - name: this + description: | + The variable that represents the cumulative value of the expression. + - name: value + description: | + The variable that refers to the element being processed. description: | A valid expression that $reduce applies to each element in the input array in left-to-right order. Wrap the input value with $reverseArray to yield the equivalent of applying the combining expression from right-to-left. During evaluation of the in expression, two variables will be available: diff --git a/generator/config/schema.json b/generator/config/schema.json index 05a16ec8a..6cf6a5130 100644 --- a/generator/config/schema.json +++ b/generator/config/schema.json @@ -117,8 +117,10 @@ "pipeline", "window", "expression", + "expressionMap", "geometry", "fieldPath", + "unprefixedFieldPath", "timeUnit", "sortSpec", "any", @@ -228,6 +230,25 @@ "$comment": "Skip the name in object encoding and merge the properties of the value into the operator", "type": "boolean", "default": false + }, + "syntheticVariables": { + "$comment": "A list of variables that are automatically made available during evaluation", + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "pattern": "^[$]?[a-zA-Z0-9]*$" + }, + "description": { + "type": "string" + } + }, + "required": [ + "name" + ] + } } }, "required": [ diff --git a/generator/config/stage/group.yaml b/generator/config/stage/group.yaml index 501776c44..a546c54e3 100644 --- a/generator/config/stage/group.yaml +++ b/generator/config/stage/group.yaml @@ -10,6 +10,7 @@ arguments: - name: _id type: - expression + - expressionMap description: | The _id expression specifies the group key. If you specify an _id value of null, or any other constant value, the $group stage returns a single document that aggregates values across all of the input documents. - name: field diff --git a/generator/config/stage/unset.yaml b/generator/config/stage/unset.yaml index be03479da..39a7a81a3 100644 --- a/generator/config/stage/unset.yaml +++ b/generator/config/stage/unset.yaml @@ -10,7 +10,7 @@ description: | arguments: - name: field type: - - fieldPath + - unprefixedFieldPath variadic: array tests: - name: Remove a Single Field From 360230357acb21f6c0eeb5e1a343f4cce06200ae Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Tue, 3 Jun 2025 22:53:18 +0200 Subject: [PATCH 13/16] fix names to align with docs --- generator/config/query/and.yaml | 2 +- generator/config/query/eq.yaml | 28 +++++---------------------- generator/config/query/exists.yaml | 16 ++------------- generator/config/query/geoWithin.yaml | 8 ++++++-- generator/config/query/gt.yaml | 2 +- generator/config/query/gte.yaml | 2 +- generator/config/query/lt.yaml | 2 +- generator/config/query/lte.yaml | 2 +- generator/config/query/nor.yaml | 4 ++++ generator/config/query/or.yaml | 4 ++++ generator/config/query/size.yaml | 9 +++++++++ generator/config/query/type.yaml | 6 +++--- 12 files changed, 38 insertions(+), 47 deletions(-) diff --git a/generator/config/query/and.yaml b/generator/config/query/and.yaml index f41441507..93f86447f 100644 --- a/generator/config/query/and.yaml +++ b/generator/config/query/and.yaml @@ -29,7 +29,7 @@ tests: - bsonType: Double qty: types: - - bsonType: Int32 + - bsonType: Double - bsonType: Undefined sale: types: diff --git a/generator/config/query/eq.yaml b/generator/config/query/eq.yaml index 746440243..fca3f1096 100644 --- a/generator/config/query/eq.yaml +++ b/generator/config/query/eq.yaml @@ -9,7 +9,7 @@ description: | arguments: - name: value type: - - any + - expression tests: - name: Equals a Specified Value link: https://www.mongodb.com/docs/manual/reference/operator/query/eq/#equals-a-specified-value @@ -123,28 +123,10 @@ tests: company: $eq: !bson_regex ^MongoDB schema: - inventory: + companies: _id: types: - - bsonType: Number - item: - types: - - bsonType: Document - fields: - name: - types: - - bsonType: String - code: - types: - - bsonType: String - qty: - types: - - bsonType: Number - tags: + - bsonType: Int32 + company: types: - - bsonType: Array - types: - - bsonType: String - - bsonType: Array - types: - - bsonType: String + - bsonType: String diff --git a/generator/config/query/exists.yaml b/generator/config/query/exists.yaml index f950ccf5a..353677f90 100644 --- a/generator/config/query/exists.yaml +++ b/generator/config/query/exists.yaml @@ -22,7 +22,7 @@ tests: - 5 - 15 schema: - inventory: + inventory: &ref_0 price: types: - bsonType: Double @@ -40,16 +40,4 @@ tests: qty: $exists: true schema: - spices: - saffron: - types: - - bsonType: Number - - bsonType: 'Null' - cinnamon: - types: - - bsonType: Number - - bsonType: 'Null' - mustard: - types: - - bsonType: Number - - bsonType: 'Null' + inventory: *ref_0 diff --git a/generator/config/query/geoWithin.yaml b/generator/config/query/geoWithin.yaml index 5611d681f..8363e5612 100644 --- a/generator/config/query/geoWithin.yaml +++ b/generator/config/query/geoWithin.yaml @@ -31,7 +31,7 @@ tests: - 0 schema: places: &ref_0 - location: + loc: types: - bsonType: Document fields: @@ -42,7 +42,11 @@ tests: types: - bsonType: Array types: - - bsonType: Double + - bsonType: Array + types: + - bsonType: Array + types: + - bsonType: Double - name: Within a Big Polygon link: https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/#within-a--big--polygon pipeline: diff --git a/generator/config/query/gt.yaml b/generator/config/query/gt.yaml index afc82ad76..147d2d57c 100644 --- a/generator/config/query/gt.yaml +++ b/generator/config/query/gt.yaml @@ -15,7 +15,7 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/query/gt/#match-document-fields pipeline: - $match: - qty: + quantity: $gt: 20 schema: inventory: diff --git a/generator/config/query/gte.yaml b/generator/config/query/gte.yaml index c4ab311e8..3b8e421bd 100644 --- a/generator/config/query/gte.yaml +++ b/generator/config/query/gte.yaml @@ -15,7 +15,7 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/query/gte/#match-document-fields pipeline: - $match: - qty: + quantity: $gte: 20 schema: inventory: diff --git a/generator/config/query/lt.yaml b/generator/config/query/lt.yaml index 9db08a5ff..c9e6c264c 100644 --- a/generator/config/query/lt.yaml +++ b/generator/config/query/lt.yaml @@ -15,7 +15,7 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/query/lt/#match-document-fields pipeline: - $match: - qty: + quantity: $lt: 20 schema: inventory: diff --git a/generator/config/query/lte.yaml b/generator/config/query/lte.yaml index a124d76d6..b39775396 100644 --- a/generator/config/query/lte.yaml +++ b/generator/config/query/lte.yaml @@ -15,7 +15,7 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/query/lte/#match-document-fields pipeline: - $match: - qty: + quantity: $lte: 20 schema: inventory: diff --git a/generator/config/query/nor.yaml b/generator/config/query/nor.yaml index cdfeb9d5d..953bae8e9 100644 --- a/generator/config/query/nor.yaml +++ b/generator/config/query/nor.yaml @@ -29,6 +29,10 @@ tests: types: - bsonType: Int32 - bsonType: Undefined + quantity: + types: + - bsonType: Int32 + - bsonType: Undefined sale: types: - bsonType: Boolean diff --git a/generator/config/query/or.yaml b/generator/config/query/or.yaml index 69b9d627d..dea9513e1 100644 --- a/generator/config/query/or.yaml +++ b/generator/config/query/or.yaml @@ -30,6 +30,10 @@ tests: types: - bsonType: Int32 - bsonType: Undefined + quantity: + types: + - bsonType: Int32 + - bsonType: Undefined sale: types: - bsonType: Boolean diff --git a/generator/config/query/size.yaml b/generator/config/query/size.yaml index 16caa841c..237f0e535 100644 --- a/generator/config/query/size.yaml +++ b/generator/config/query/size.yaml @@ -26,6 +26,15 @@ tests: types: - bsonType: Int32 - bsonType: Undefined + quantity: + types: + - bsonType: Int32 + - bsonType: Undefined sale: types: - bsonType: Boolean + tags: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/query/type.yaml b/generator/config/query/type.yaml index 26a1cec65..43f5c4709 100644 --- a/generator/config/query/type.yaml +++ b/generator/config/query/type.yaml @@ -57,12 +57,12 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-multiple-data-types pipeline: - $match: - zipCode: + classAverage: $type: - 2 - 1 - $match: - zipCode: + classAverage: $type: - string - double @@ -111,7 +111,7 @@ tests: link: https://www.mongodb.com/docs/manual/reference/operator/query/type/#querying-by-array-type pipeline: - $match: - zipCode: + readings: $type: - array schema: From 7978e4fcf6fb84a46d97e6119f9a80b2b09419d6 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Tue, 3 Jun 2025 23:17:38 +0200 Subject: [PATCH 14/16] regenerate test schemas --- generator/config/accumulator/stdDevSamp.yaml | 2 +- generator/config/expression/add.yaml | 4 ++-- generator/config/expression/arrayElemAt.yaml | 2 +- generator/config/expression/cond.yaml | 2 +- generator/config/expression/dateAdd.yaml | 2 +- generator/config/expression/let.yaml | 2 +- generator/config/expression/ln.yaml | 2 +- generator/config/expression/reverseArray.yaml | 2 +- generator/config/expression/setField.yaml | 4 ++-- generator/config/expression/slice.yaml | 2 +- generator/config/expression/sqrt.yaml | 2 +- generator/config/expression/sum.yaml | 2 +- generator/config/query/and.yaml | 11 ++++++++++- generator/config/query/exists.yaml | 9 +++++++++ generator/config/query/nor.yaml | 5 +++++ generator/config/query/not.yaml | 9 +++++++++ generator/config/query/or.yaml | 5 +++++ generator/config/stage/redact.yaml | 4 ++-- 18 files changed, 54 insertions(+), 17 deletions(-) diff --git a/generator/config/accumulator/stdDevSamp.yaml b/generator/config/accumulator/stdDevSamp.yaml index 920be3833..ca0e1b300 100644 --- a/generator/config/accumulator/stdDevSamp.yaml +++ b/generator/config/accumulator/stdDevSamp.yaml @@ -24,7 +24,7 @@ tests: ageStdDev: $stdDevSamp: $age schema: - TestCollection: + users: _id: types: - bsonType: Number diff --git a/generator/config/expression/add.yaml b/generator/config/expression/add.yaml index a2471af23..27268071d 100644 --- a/generator/config/expression/add.yaml +++ b/generator/config/expression/add.yaml @@ -29,7 +29,7 @@ tests: - $price - $fee schema: - TestCollection: + sales: _id: types: - bsonType: Number @@ -55,7 +55,7 @@ tests: - $date - 259200000 schema: - TestCollection: + sales: _id: types: - bsonType: Number diff --git a/generator/config/expression/arrayElemAt.yaml b/generator/config/expression/arrayElemAt.yaml index da290621c..c774ebca4 100644 --- a/generator/config/expression/arrayElemAt.yaml +++ b/generator/config/expression/arrayElemAt.yaml @@ -28,7 +28,7 @@ tests: - $favorites - -1 schema: - TestCollection: + users: _id: types: - bsonType: Number diff --git a/generator/config/expression/cond.yaml b/generator/config/expression/cond.yaml index e968a2847..12d4be93b 100644 --- a/generator/config/expression/cond.yaml +++ b/generator/config/expression/cond.yaml @@ -31,7 +31,7 @@ tests: then: 30 else: 20 schema: - TestCollection: + inventory: _id: types: - bsonType: Number diff --git a/generator/config/expression/dateAdd.yaml b/generator/config/expression/dateAdd.yaml index 5ab2d5a42..caaec955d 100644 --- a/generator/config/expression/dateAdd.yaml +++ b/generator/config/expression/dateAdd.yaml @@ -75,7 +75,7 @@ tests: shipping: custId: types: - - bsonType: Number + - bsonType: Int32 purchaseDate: types: - bsonType: Date diff --git a/generator/config/expression/let.yaml b/generator/config/expression/let.yaml index be170126e..426364496 100644 --- a/generator/config/expression/let.yaml +++ b/generator/config/expression/let.yaml @@ -41,7 +41,7 @@ tests: - $$total - $$discounted schema: - TestCollection: + sales: _id: types: - bsonType: Number diff --git a/generator/config/expression/ln.yaml b/generator/config/expression/ln.yaml index 8f2896eec..7788a3f9d 100644 --- a/generator/config/expression/ln.yaml +++ b/generator/config/expression/ln.yaml @@ -22,7 +22,7 @@ tests: y: $ln: $sales schema: - TestCollection: + sales: _id: types: - bsonType: Number diff --git a/generator/config/expression/reverseArray.yaml b/generator/config/expression/reverseArray.yaml index 55290f595..6733a780a 100644 --- a/generator/config/expression/reverseArray.yaml +++ b/generator/config/expression/reverseArray.yaml @@ -21,7 +21,7 @@ tests: reverseFavorites: $reverseArray: $favorites schema: - TestCollection: + users: _id: types: - bsonType: Number diff --git a/generator/config/expression/setField.yaml b/generator/config/expression/setField.yaml index fa1a71f33..78049510a 100644 --- a/generator/config/expression/setField.yaml +++ b/generator/config/expression/setField.yaml @@ -162,9 +162,9 @@ tests: item: types: - bsonType: String - price: + qty: types: - bsonType: Number - qty: + $price: types: - bsonType: Number diff --git a/generator/config/expression/slice.yaml b/generator/config/expression/slice.yaml index 0abdb444d..a2d32f674 100644 --- a/generator/config/expression/slice.yaml +++ b/generator/config/expression/slice.yaml @@ -38,7 +38,7 @@ tests: - $favorites - 3 schema: - TestCollection: + users: _id: types: - bsonType: Number diff --git a/generator/config/expression/sqrt.yaml b/generator/config/expression/sqrt.yaml index 860731699..40f8ed742 100644 --- a/generator/config/expression/sqrt.yaml +++ b/generator/config/expression/sqrt.yaml @@ -31,7 +31,7 @@ tests: - $p1.x - 2 schema: - TestCollection: + points: _id: types: - bsonType: Number diff --git a/generator/config/expression/sum.yaml b/generator/config/expression/sum.yaml index bb4ed3a48..7e3e359df 100644 --- a/generator/config/expression/sum.yaml +++ b/generator/config/expression/sum.yaml @@ -29,7 +29,7 @@ tests: - $final - $midterm schema: - TestCollection: + students: _id: types: - bsonType: Number diff --git a/generator/config/query/and.yaml b/generator/config/query/and.yaml index 93f86447f..dcf231c02 100644 --- a/generator/config/query/and.yaml +++ b/generator/config/query/and.yaml @@ -29,11 +29,20 @@ tests: - bsonType: Double qty: types: - - bsonType: Double + - bsonType: Int32 + - bsonType: Undefined + quantity: + types: + - bsonType: Int32 - bsonType: Undefined sale: types: - bsonType: Boolean + tags: + types: + - bsonType: Array + types: + - bsonType: String - 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: diff --git a/generator/config/query/exists.yaml b/generator/config/query/exists.yaml index 353677f90..ff5997fde 100644 --- a/generator/config/query/exists.yaml +++ b/generator/config/query/exists.yaml @@ -30,9 +30,18 @@ tests: types: - bsonType: Int32 - bsonType: Undefined + quantity: + types: + - bsonType: Int32 + - bsonType: Undefined sale: types: - bsonType: Boolean + tags: + types: + - bsonType: Array + types: + - bsonType: String - name: Null Values link: https://www.mongodb.com/docs/manual/reference/operator/query/exists/#null-values pipeline: diff --git a/generator/config/query/nor.yaml b/generator/config/query/nor.yaml index 953bae8e9..a609e6431 100644 --- a/generator/config/query/nor.yaml +++ b/generator/config/query/nor.yaml @@ -36,6 +36,11 @@ tests: sale: types: - bsonType: Boolean + tags: + types: + - bsonType: Array + types: + - bsonType: String - name: Additional Comparisons link: https://www.mongodb.com/docs/manual/reference/operator/query/nor/#-nor-and-additional-comparisons pipeline: diff --git a/generator/config/query/not.yaml b/generator/config/query/not.yaml index cb4ebe62a..a4b98f920 100644 --- a/generator/config/query/not.yaml +++ b/generator/config/query/not.yaml @@ -27,9 +27,18 @@ tests: types: - bsonType: Int32 - bsonType: Undefined + quantity: + types: + - bsonType: Int32 + - bsonType: Undefined sale: types: - bsonType: Boolean + tags: + types: + - bsonType: Array + types: + - bsonType: String - name: Regular Expressions link: https://www.mongodb.com/docs/manual/reference/operator/query/not/#regular-expressions pipeline: diff --git a/generator/config/query/or.yaml b/generator/config/query/or.yaml index dea9513e1..25fc4038b 100644 --- a/generator/config/query/or.yaml +++ b/generator/config/query/or.yaml @@ -37,6 +37,11 @@ tests: sale: types: - bsonType: Boolean + tags: + types: + - bsonType: Array + types: + - bsonType: String - name: Error Handling link: https://www.mongodb.com/docs/manual/reference/operator/query/or/#error-handling pipeline: diff --git a/generator/config/stage/redact.yaml b/generator/config/stage/redact.yaml index 453850a38..0fe938250 100644 --- a/generator/config/stage/redact.yaml +++ b/generator/config/stage/redact.yaml @@ -29,7 +29,7 @@ tests: then: $$DESCEND else: $$PRUNE schema: - TestCollection: + forecasts: _id: types: - bsonType: Number @@ -85,7 +85,7 @@ tests: then: $$PRUNE else: $$DESCEND schema: - TestCollection: + forecasts: _id: types: - bsonType: Number From b9b1d19f73fb8df972051136af80f0b61a87cee8 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 4 Jun 2025 03:43:01 +0200 Subject: [PATCH 15/16] add searchHighlight as a type --- generator/config/schema.json | 3 ++- generator/config/search/in.yaml | 3 +++ generator/config/stage/search.yaml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/generator/config/schema.json b/generator/config/schema.json index 6cf6a5130..da0a65286 100644 --- a/generator/config/schema.json +++ b/generator/config/schema.json @@ -184,7 +184,8 @@ "decimal", "searchPath", "searchScore", - "searchOperator" + "searchOperator", + "searchHighlight" ] } }, diff --git a/generator/config/search/in.yaml b/generator/config/search/in.yaml index cd1688aac..04f2cf7a6 100644 --- a/generator/config/search/in.yaml +++ b/generator/config/search/in.yaml @@ -35,6 +35,9 @@ tests: birthdate: 1 schema: customers: &ref_0 + _id: + types: + - bsonType: ObjectId username: types: - bsonType: String diff --git a/generator/config/stage/search.yaml b/generator/config/stage/search.yaml index e1d41f22a..943fe7717 100644 --- a/generator/config/stage/search.yaml +++ b/generator/config/stage/search.yaml @@ -24,7 +24,7 @@ arguments: - name: highlight optional: true type: - - object + - searchHighlight description: | Specifies the highlighting options for displaying search terms in their original context. - name: concurrent From c2b1ee5233ee16d07a1541b381184bfcdfae9cf2 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 4 Jun 2025 11:23:00 +0200 Subject: [PATCH 16/16] Add schema for first/last --- generator/config/expression/first.yaml | 8 +++++++- generator/config/expression/last.yaml | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/generator/config/expression/first.yaml b/generator/config/expression/first.yaml index caf5ed2ca..0926c5d65 100644 --- a/generator/config/expression/first.yaml +++ b/generator/config/expression/first.yaml @@ -16,4 +16,10 @@ tests: - $addFields: firstItem: $first: $items - schema: '// TODO: No docs reference found' + schema: + collection: + items: + types: + - bsonType: Array + types: + - bsonType: String diff --git a/generator/config/expression/last.yaml b/generator/config/expression/last.yaml index 5f2378a85..976e2f3e0 100644 --- a/generator/config/expression/last.yaml +++ b/generator/config/expression/last.yaml @@ -16,4 +16,10 @@ tests: - $addFields: lastItem: $last: $items - schema: '// TODO: No docs reference found' + schema: + collection: + items: + types: + - bsonType: Array + types: + - bsonType: String