Skip to content

Commit cb2571c

Browse files
committed
generate schema for accumulators
1 parent 7cb2274 commit cb2571c

34 files changed

+1057
-1
lines changed

generator/config/accumulator/accumulator.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ tests:
7979
return (state.sum / state.count)
8080
}
8181
lang: js
82+
schema:
83+
books:
84+
_id:
85+
types:
86+
- bsonType: Number
87+
title:
88+
types:
89+
- bsonType: String
90+
author:
91+
types:
92+
- bsonType: String
93+
copies:
94+
types:
95+
- bsonType: Number
8296
- name: Use initArgs to Vary the Initial State by Group
8397
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/#use-initargs-to-vary-the-initial-state-by-group
8498
pipeline:
@@ -119,3 +133,17 @@ tests:
119133
return state.restaurants
120134
}
121135
lang: js
136+
schema:
137+
restaurants:
138+
_id:
139+
types:
140+
- bsonType: Number
141+
name:
142+
types:
143+
- bsonType: String
144+
city:
145+
types:
146+
- bsonType: String
147+
cuisine:
148+
types:
149+
- bsonType: String

generator/config/accumulator/addToSet.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@ tests:
2626
date: $date
2727
itemsSold:
2828
$addToSet: $item
29+
schema:
30+
sales:
31+
_id:
32+
types:
33+
- bsonType: Number
34+
item:
35+
types:
36+
- bsonType: String
37+
price:
38+
types:
39+
- bsonType: Number
40+
quantity:
41+
types:
42+
- bsonType: Number
43+
date:
44+
types:
45+
- bsonType: Date
2946
- name: Use in $setWindowFields Stage
3047
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/#use-in--setwindowfields-stage
3148
pipeline:
@@ -40,3 +57,23 @@ tests:
4057
documents:
4158
- unbounded
4259
- current
60+
schema:
61+
cakeSales:
62+
_id:
63+
types:
64+
- bsonType: Number
65+
type:
66+
types:
67+
- bsonType: String
68+
orderDate:
69+
types:
70+
- bsonType: Date
71+
state:
72+
types:
73+
- bsonType: String
74+
price:
75+
types:
76+
- bsonType: Number
77+
quantity:
78+
types:
79+
- bsonType: Number

generator/config/accumulator/avg.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ tests:
2525
- $quantity
2626
avgQuantity:
2727
$avg: $quantity
28+
schema:
29+
sales:
30+
_id:
31+
types:
32+
- bsonType: Number
33+
item:
34+
types:
35+
- bsonType: String
36+
price:
37+
types:
38+
- bsonType: Number
39+
quantity:
40+
types:
41+
- bsonType: Number
42+
date:
43+
types:
44+
- bsonType: Date
2845
- name: Use in $setWindowFields Stage
2946
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/#use-in--setwindowfields-stage
3047
pipeline:
@@ -39,3 +56,23 @@ tests:
3956
documents:
4057
- unbounded
4158
- current
59+
schema:
60+
cakeSales:
61+
_id:
62+
types:
63+
- bsonType: Number
64+
type:
65+
types:
66+
- bsonType: String
67+
orderDate:
68+
types:
69+
- bsonType: Date
70+
state:
71+
types:
72+
- bsonType: String
73+
price:
74+
types:
75+
- bsonType: Number
76+
quantity:
77+
types:
78+
- bsonType: Number

generator/config/accumulator/bottom.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ tests:
3434
- $score
3535
sortBy:
3636
score: -1
37+
schema:
38+
gamescores:
39+
playerId:
40+
types:
41+
- bsonType: String
42+
gameId:
43+
types:
44+
- bsonType: String
45+
score:
46+
types:
47+
- bsonType: Number
3748
- name: Finding the Bottom Score Across Multiple Games
3849
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/#finding-the-bottom-score-across-multiple-games
3950
pipeline:
@@ -46,3 +57,14 @@ tests:
4657
- $score
4758
sortBy:
4859
score: -1
60+
schema:
61+
gamescores:
62+
playerId:
63+
types:
64+
- bsonType: String
65+
gameId:
66+
types:
67+
- bsonType: String
68+
score:
69+
types:
70+
- bsonType: Number

generator/config/accumulator/bottomN.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ tests:
4141
sortBy:
4242
score: -1
4343
n: 3
44+
schema:
45+
gamescores:
46+
playerId:
47+
types:
48+
- bsonType: String
49+
gameId:
50+
types:
51+
- bsonType: String
52+
score:
53+
types:
54+
- bsonType: Number
4455
- name: Finding the Three Lowest Score Documents Across Multiple Games
4556
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/#finding-the-three-lowest-score-documents-across-multiple-games
4657
pipeline:
@@ -54,6 +65,17 @@ tests:
5465
sortBy:
5566
score: -1
5667
n: 3
68+
schema:
69+
gamescores:
70+
playerId:
71+
types:
72+
- bsonType: String
73+
gameId:
74+
types:
75+
- bsonType: String
76+
score:
77+
types:
78+
- bsonType: Number
5779
- name: Computing n Based on the Group Key for $group
5880
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/#computing-n-based-on-the-group-key-for--group
5981
pipeline:
@@ -73,3 +95,14 @@ tests:
7395
else: 3
7496
sortBy:
7597
score: -1
98+
schema:
99+
gamescores:
100+
playerId:
101+
types:
102+
- bsonType: String
103+
gameId:
104+
types:
105+
- bsonType: String
106+
score:
107+
types:
108+
- bsonType: Number

generator/config/accumulator/count.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ tests:
1717
_id: $state
1818
countNumberOfDocumentsForState:
1919
$count: {}
20+
schema:
21+
cakeSales:
22+
_id:
23+
types:
24+
- bsonType: Number
25+
type:
26+
types:
27+
- bsonType: String
28+
orderDate:
29+
types:
30+
- bsonType: Date
31+
state:
32+
types:
33+
- bsonType: String
34+
price:
35+
types:
36+
- bsonType: Number
37+
quantity:
38+
types:
39+
- bsonType: Number
2040
- name: Use in $setWindowFields Stage
2141
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/count-accumulator/#use-in--setwindowfields-stage
2242
pipeline:
@@ -31,3 +51,23 @@ tests:
3151
documents:
3252
- unbounded
3353
- current
54+
schema:
55+
cakeSales:
56+
_id:
57+
types:
58+
- bsonType: Number
59+
type:
60+
types:
61+
- bsonType: String
62+
orderDate:
63+
types:
64+
- bsonType: Date
65+
state:
66+
types:
67+
- bsonType: String
68+
price:
69+
types:
70+
- bsonType: Number
71+
quantity:
72+
types:
73+
- bsonType: Number

generator/config/accumulator/covariancePop.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,23 @@ tests:
3232
documents:
3333
- unbounded
3434
- current
35+
schema:
36+
cakeSales:
37+
_id:
38+
types:
39+
- bsonType: Number
40+
type:
41+
types:
42+
- bsonType: String
43+
orderDate:
44+
types:
45+
- bsonType: Date
46+
state:
47+
types:
48+
- bsonType: String
49+
price:
50+
types:
51+
- bsonType: Number
52+
quantity:
53+
types:
54+
- bsonType: Number

generator/config/accumulator/covarianceSamp.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,23 @@ tests:
3232
documents:
3333
- unbounded
3434
- current
35+
schema:
36+
cakeSales:
37+
_id:
38+
types:
39+
- bsonType: Number
40+
type:
41+
types:
42+
- bsonType: String
43+
orderDate:
44+
types:
45+
- bsonType: Date
46+
state:
47+
types:
48+
- bsonType: String
49+
price:
50+
types:
51+
- bsonType: Number
52+
quantity:
53+
types:
54+
- bsonType: Number

generator/config/accumulator/denseRank.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ tests:
1818
output:
1919
denseRankQuantityForState:
2020
$denseRank: {}
21+
schema:
22+
cakeSales:
23+
_id:
24+
types:
25+
- bsonType: Number
26+
type:
27+
types:
28+
- bsonType: String
29+
orderDate:
30+
types:
31+
- bsonType: Date
32+
state:
33+
types:
34+
- bsonType: String
35+
price:
36+
types:
37+
- bsonType: Number
38+
quantity:
39+
types:
40+
- bsonType: Number
2141
- name: Dense Rank Partitions by a Date Field
2242
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/#dense-rank-partitions-by-a-date-field
2343
pipeline:
@@ -28,3 +48,23 @@ tests:
2848
output:
2949
denseRankOrderDateForState:
3050
$denseRank: {}
51+
schema:
52+
cakeSales:
53+
_id:
54+
types:
55+
- bsonType: Number
56+
type:
57+
types:
58+
- bsonType: String
59+
orderDate:
60+
types:
61+
- bsonType: Date
62+
state:
63+
types:
64+
- bsonType: String
65+
price:
66+
types:
67+
- bsonType: Number
68+
quantity:
69+
types:
70+
- bsonType: Number

generator/config/accumulator/derivative.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,14 @@ tests:
4040
- $match:
4141
truckAverageSpeed:
4242
$gt: 50
43+
schema:
44+
deliveryFleet:
45+
truckID:
46+
types:
47+
- bsonType: String
48+
timeStamp:
49+
types:
50+
- bsonType: Date
51+
miles:
52+
types:
53+
- bsonType: Number

0 commit comments

Comments
 (0)