Skip to content

Commit 07cd9fc

Browse files
committed
run yamlfix
1 parent 7e64509 commit 07cd9fc

File tree

289 files changed

+10005
-11885
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+10005
-11885
lines changed

generator/config/.yamlfix.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
allow_duplicate_keys = false
2+
comments_min_spaces_from_content = 1
3+
sequence_style = "block_style"
4+
indent_mapping = 4
5+
indent_offset = 4
6+
indent_sequence = 6
7+
none_representation = "~"
8+
explicit_start = false
Lines changed: 108 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,121 @@
11
# $schema: ../schema.json
22
name: $accumulator
3-
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/'
3+
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/
44
type:
55
- accumulator
66
encode: object
77
description: |
88
Defines a custom accumulator function.
99
New in MongoDB 4.4.
1010
arguments:
11-
-
12-
name: init
13-
type:
14-
- javascript
15-
description: |
16-
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.
17-
-
18-
name: initArgs
19-
type:
20-
- resolvesToArray
21-
optional: true
22-
description: |
23-
Arguments passed to the init function.
24-
-
25-
name: accumulate
26-
type:
27-
- javascript
28-
description: |
29-
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.
30-
-
31-
name: accumulateArgs
32-
type:
33-
- resolvesToArray
34-
description: |
35-
Arguments passed to the accumulate function. You can use accumulateArgs to specify what field value(s) to pass to the accumulate function.
36-
-
37-
name: merge
38-
type:
39-
- javascript
40-
description: |
41-
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.
42-
-
43-
name: finalize
44-
type:
45-
- javascript
46-
optional: true
47-
description: |
48-
Function used to update the result of the accumulation.
49-
-
50-
name: lang
51-
type:
52-
- string
53-
description: |
54-
The language used in the $accumulator code.
55-
11+
- name: init
12+
type:
13+
- javascript
14+
description: |
15+
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.
16+
- name: initArgs
17+
type:
18+
- resolvesToArray
19+
optional: true
20+
description: |
21+
Arguments passed to the init function.
22+
- name: accumulate
23+
type:
24+
- javascript
25+
description: |
26+
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.
27+
- name: accumulateArgs
28+
type:
29+
- resolvesToArray
30+
description: |
31+
Arguments passed to the accumulate function. You can use accumulateArgs to specify what field value(s) to pass to the accumulate function.
32+
- name: merge
33+
type:
34+
- javascript
35+
description: |
36+
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.
37+
- name: finalize
38+
type:
39+
- javascript
40+
optional: true
41+
description: |
42+
Function used to update the result of the accumulation.
43+
- name: lang
44+
type:
45+
- string
46+
description: |
47+
The language used in the $accumulator code.
5648
tests:
57-
-
58-
name: 'Use $accumulator to Implement the $avg Operator'
59-
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#use--accumulator-to-implement-the--avg-operator'
60-
pipeline:
61-
-
62-
$group:
63-
_id: '$author'
64-
avgCopies:
65-
$accumulator:
66-
init:
67-
$code: |-
68-
function() {
69-
return { count: 0, sum: 0 }
49+
- name: Use $accumulator to Implement the $avg Operator
50+
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#use--accumulator-to-implement-the--avg-operator
51+
pipeline:
52+
- $group:
53+
_id: $author
54+
avgCopies:
55+
$accumulator:
56+
init:
57+
$code: |-
58+
function() {
59+
return { count: 0, sum: 0 }
60+
}
61+
accumulate:
62+
$code: |-
63+
function(state, numCopies) {
64+
return { count: state.count + 1, sum: state.sum + numCopies }
65+
}
66+
accumulateArgs:
67+
- $copies
68+
merge:
69+
$code: |-
70+
function(state1, state2) {
71+
return {
72+
count: state1.count + state2.count,
73+
sum: state1.sum + state2.sum
7074
}
71-
accumulate:
72-
$code: |-
73-
function(state, numCopies) {
74-
return { count: state.count + 1, sum: state.sum + numCopies }
75+
}
76+
finalize:
77+
$code: |-
78+
function(state) {
79+
return (state.sum / state.count)
80+
}
81+
lang: js
82+
- name: Use initArgs to Vary the Initial State by Group
83+
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#use-initargs-to-vary-the-initial-state-by-group
84+
pipeline:
85+
- $group:
86+
_id:
87+
city: $city
88+
restaurants:
89+
$accumulator:
90+
init:
91+
$code: |-
92+
function(city, userProfileCity) {
93+
return { max: city === userProfileCity ? 3 : 1, restaurants: [] }
94+
}
95+
initArgs:
96+
- $city
97+
- Bettles
98+
accumulate:
99+
$code: |-
100+
function(state, restaurantName) {
101+
if (state.restaurants.length < state.max) {
102+
state.restaurants.push(restaurantName);
75103
}
76-
accumulateArgs: [ "$copies" ]
77-
merge:
78-
$code: |-
79-
function(state1, state2) {
80-
return {
81-
count: state1.count + state2.count,
82-
sum: state1.sum + state2.sum
83-
}
104+
return state;
105+
}
106+
accumulateArgs:
107+
- $name
108+
merge:
109+
$code: |-
110+
function(state1, state2) {
111+
return {
112+
max: state1.max,
113+
restaurants: state1.restaurants.concat(state2.restaurants).slice(0, state1.max)
84114
}
85-
finalize:
86-
$code: |-
87-
function(state) {
88-
return (state.sum / state.count)
89-
}
90-
lang: 'js'
91-
92-
-
93-
name: 'Use initArgs to Vary the Initial State by Group'
94-
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#use-initargs-to-vary-the-initial-state-by-group'
95-
pipeline:
96-
-
97-
$group:
98-
_id:
99-
city: '$city'
100-
restaurants:
101-
$accumulator:
102-
init:
103-
$code: |-
104-
function(city, userProfileCity) {
105-
return { max: city === userProfileCity ? 3 : 1, restaurants: [] }
106-
}
107-
initArgs:
108-
- '$city'
109-
- 'Bettles'
110-
accumulate:
111-
$code: |-
112-
function(state, restaurantName) {
113-
if (state.restaurants.length < state.max) {
114-
state.restaurants.push(restaurantName);
115-
}
116-
return state;
117-
}
118-
accumulateArgs: ['$name']
119-
merge:
120-
$code: |-
121-
function(state1, state2) {
122-
return {
123-
max: state1.max,
124-
restaurants: state1.restaurants.concat(state2.restaurants).slice(0, state1.max)
125-
}
126-
}
127-
finalize:
128-
$code: |-
129-
function(state) {
130-
return state.restaurants
131-
}
132-
lang: 'js'
115+
}
116+
finalize:
117+
$code: |-
118+
function(state) {
119+
return state.restaurants
120+
}
121+
lang: js
Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# $schema: ../schema.json
22
name: $addToSet
3-
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/'
3+
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/
44
type:
55
- accumulator
66
- window
@@ -9,39 +9,34 @@ description: |
99
Returns an array of unique expression values for each group. Order of the array elements is undefined.
1010
Changed in MongoDB 5.0: Available in the $setWindowFields stage.
1111
arguments:
12-
-
13-
name: expression
14-
type:
15-
- expression
16-
12+
- name: expression
13+
type:
14+
- expression
1715
tests:
18-
-
19-
name: 'Use in $group Stage'
20-
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--group-stage'
21-
pipeline:
22-
- $group:
16+
- name: Use in $group Stage
17+
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--group-stage
18+
pipeline:
19+
- $group:
2320
_id:
2421
day:
2522
$dayOfYear:
26-
date: '$date'
23+
date: $date
2724
year:
2825
$year:
29-
date: '$date'
26+
date: $date
3027
itemsSold:
31-
$addToSet: '$item'
32-
-
33-
name: 'Use in $setWindowFields Stage'
34-
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--setwindowfields-stage'
35-
pipeline:
36-
-
37-
$setWindowFields:
38-
partitionBy: '$state'
39-
sortBy:
40-
orderDate: 1
41-
output:
42-
cakeTypesForState:
43-
$addToSet: '$type'
44-
window:
45-
documents:
46-
- 'unbounded'
47-
- 'current'
28+
$addToSet: $item
29+
- name: Use in $setWindowFields Stage
30+
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--setwindowfields-stage
31+
pipeline:
32+
- $setWindowFields:
33+
partitionBy: $state
34+
sortBy:
35+
orderDate: 1
36+
output:
37+
cakeTypesForState:
38+
$addToSet: $type
39+
window:
40+
documents:
41+
- unbounded
42+
- current

generator/config/accumulator/avg.yaml

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# $schema: ../schema.json
22
name: $avg
3-
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/'
3+
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/
44
type:
55
- accumulator
66
- window
@@ -9,37 +9,33 @@ description: |
99
Returns an average of numerical values. Ignores non-numeric values.
1010
Changed in MongoDB 5.0: Available in the $setWindowFields stage.
1111
arguments:
12-
-
13-
name: expression
14-
type:
15-
- resolvesToNumber
12+
- name: expression
13+
type:
14+
- resolvesToNumber
1615
tests:
17-
-
18-
name: 'Use in $group Stage'
19-
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--group-stage'
20-
pipeline:
21-
- $group:
22-
_id: '$item'
23-
avgAmount:
24-
$avg:
25-
$multiply:
26-
- '$price'
27-
- '$quantity'
28-
avgQuantity:
29-
$avg: '$quantity'
30-
-
31-
name: 'Use in $setWindowFields Stage'
32-
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--setwindowfields-stage'
33-
pipeline:
34-
-
35-
$setWindowFields:
36-
partitionBy: '$state'
37-
sortBy:
38-
orderDate: 1
39-
output:
40-
averageQuantityForState:
41-
$avg: '$quantity'
42-
window:
43-
documents:
44-
- 'unbounded'
45-
- 'current'
16+
- name: Use in $group Stage
17+
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--group-stage
18+
pipeline:
19+
- $group:
20+
_id: $item
21+
avgAmount:
22+
$avg:
23+
$multiply:
24+
- $price
25+
- $quantity
26+
avgQuantity:
27+
$avg: $quantity
28+
- name: Use in $setWindowFields Stage
29+
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--setwindowfields-stage
30+
pipeline:
31+
- $setWindowFields:
32+
partitionBy: $state
33+
sortBy:
34+
orderDate: 1
35+
output:
36+
averageQuantityForState:
37+
$avg: $quantity
38+
window:
39+
documents:
40+
- unbounded
41+
- current

0 commit comments

Comments
 (0)