Skip to content

Commit 6a34eda

Browse files
committed
schema for stages
1 parent 64a44ad commit 6a34eda

Some content is hidden

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

43 files changed

+2160
-9
lines changed

generator/config/stage/addFields.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,66 @@ tests:
3030
- $totalHomework
3131
- $totalQuiz
3232
- $extraCredit
33+
schema:
34+
scores:
35+
_id:
36+
types:
37+
- bsonType: Number
38+
student:
39+
types:
40+
- bsonType: String
41+
homework:
42+
types:
43+
- bsonType: Array
44+
types:
45+
- bsonType: Number
46+
quiz:
47+
types:
48+
- bsonType: Array
49+
types:
50+
- bsonType: Number
51+
extraCredit:
52+
types:
53+
- bsonType: Number
3354
- name: Adding Fields to an Embedded Document
3455
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#adding-fields-to-an-embedded-document
3556
pipeline:
3657
- $addFields:
3758
specs.fuel_type: unleaded
59+
schema:
60+
vehicles:
61+
_id:
62+
types:
63+
- bsonType: Number
64+
type:
65+
types:
66+
- bsonType: String
67+
specs:
68+
types:
69+
- bsonType: Document
70+
fields:
71+
doors:
72+
types:
73+
- bsonType: Number
74+
wheels:
75+
types:
76+
- bsonType: Number
3877
- name: Overwriting an existing field
3978
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#overwriting-an-existing-field
4079
pipeline:
4180
- $addFields:
4281
cats: 20
82+
schema:
83+
animals:
84+
_id:
85+
types:
86+
- bsonType: Number
87+
dogs:
88+
types:
89+
- bsonType: Number
90+
cats:
91+
types:
92+
- bsonType: Number
4393
- name: Add Element to an Array
4494
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/#add-element-to-an-array
4595
pipeline:
@@ -50,3 +100,24 @@ tests:
50100
$concatArrays:
51101
- $homework
52102
- - 7
103+
schema:
104+
scores:
105+
_id:
106+
types:
107+
- bsonType: Number
108+
student:
109+
types:
110+
- bsonType: String
111+
homework:
112+
types:
113+
- bsonType: Array
114+
types:
115+
- bsonType: Number
116+
quiz:
117+
types:
118+
- bsonType: Array
119+
types:
120+
- bsonType: Number
121+
extraCredit:
122+
types:
123+
- bsonType: Number

generator/config/stage/bucket.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ tests:
6363
- $match:
6464
count:
6565
$gt: 3
66+
schema:
67+
artists:
68+
_id:
69+
types:
70+
- bsonType: Number
71+
last_name:
72+
types:
73+
- bsonType: String
74+
first_name:
75+
types:
76+
- bsonType: String
77+
year_born:
78+
types:
79+
- bsonType: Number
80+
year_died:
81+
types:
82+
- bsonType: Number
83+
nationality:
84+
types:
85+
- bsonType: String
6686
- name: Use $bucket with $facet to Bucket by Multiple Fields
6787
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/#use--bucket-with--facet-to-bucket-by-multiple-fields
6888
pipeline:
@@ -100,3 +120,20 @@ tests:
100120
$push:
101121
title: $title
102122
year: $year
123+
schema:
124+
artwork:
125+
_id:
126+
types:
127+
- bsonType: Number
128+
title:
129+
types:
130+
- bsonType: String
131+
artist:
132+
types:
133+
- bsonType: String
134+
year:
135+
types:
136+
- bsonType: Number
137+
price:
138+
types:
139+
- bsonType: Decimal128

generator/config/stage/bucketAuto.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,33 @@ tests:
3838
- $bucketAuto:
3939
groupBy: $price
4040
buckets: 4
41+
schema:
42+
artwork:
43+
_id:
44+
types:
45+
- bsonType: Int32
46+
title:
47+
types:
48+
- bsonType: String
49+
artist:
50+
types:
51+
- bsonType: String
52+
year:
53+
types:
54+
- bsonType: Int32
55+
price:
56+
types:
57+
- bsonType: Decimal128
58+
dimensions:
59+
types:
60+
- bsonType: Document
61+
fields:
62+
height:
63+
types:
64+
- bsonType: Int32
65+
width:
66+
types:
67+
- bsonType: Int32
68+
units:
69+
types:
70+
- bsonType: String

generator/config/stage/changeStream.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,8 @@ tests:
5555
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/#examples
5656
pipeline:
5757
- $changeStream: {}
58+
schema:
59+
names:
60+
_id:
61+
types:
62+
- bsonType: ObjectId

generator/config/stage/changeStreamSplitLargeEvent.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ tests:
1212
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStreamSplitLargeEvent/#example
1313
pipeline:
1414
- $changeStreamSplitLargeEvent: {}
15+
schema:
16+
myCollection:
17+
_id:
18+
types:
19+
- bsonType: Int32
20+
largeField:
21+
types:
22+
- bsonType: String

generator/config/stage/collStats.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,29 @@ tests:
3030
- $collStats:
3131
latencyStats:
3232
histograms: true
33+
schema:
34+
TestCollection: &ref_0
35+
_id:
36+
types:
37+
- bsonType: ObjectId
3338
- name: storageStats Document
3439
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#storagestats-document
3540
pipeline:
3641
- $collStats:
3742
storageStats: {}
43+
schema:
44+
TestCollection: *ref_0
3845
- name: count Field
3946
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#count-field
4047
pipeline:
4148
- $collStats:
4249
count: {}
50+
schema:
51+
TestCollection: *ref_0
4352
- name: queryExecStats Document
4453
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/#queryexecstats-document
4554
pipeline:
4655
- $collStats:
4756
queryExecStats: {}
57+
schema:
58+
TestCollection: *ref_0

generator/config/stage/count.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,20 @@ arguments:
1515
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.
1616
tests:
1717
- name: Example
18-
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/#example
18+
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/#examples
1919
pipeline:
2020
- $match:
2121
score:
2222
$gt: 80
2323
- $count: passing_scores
24+
schema:
25+
scores:
26+
_id:
27+
types:
28+
- bsonType: Number
29+
subject:
30+
types:
31+
- bsonType: String
32+
score:
33+
types:
34+
- bsonType: Number

generator/config/stage/currentOp.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ tests:
3838
active: false
3939
transaction:
4040
$exists: true
41+
schema:
42+
TestCollection: &ref_0
43+
_id:
44+
types:
45+
- bsonType: ObjectId
4146
- name: Sampled Queries
4247
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/#sampled-queries
4348
pipeline:
@@ -46,3 +51,5 @@ tests:
4651
localOps: true
4752
- $match:
4853
desc: query analyzer
54+
schema:
55+
TestCollection: *ref_0

generator/config/stage/densify.yaml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,26 @@ tests:
3737
bounds:
3838
- !bson_utcdatetime '2021-05-18T00:00:00.000Z'
3939
- !bson_utcdatetime '2021-05-18T08:00:00.000Z'
40+
schema:
41+
weather:
42+
metadata:
43+
types:
44+
- bsonType: Document
45+
fields:
46+
sensorId:
47+
types:
48+
- bsonType: Number
49+
type:
50+
types:
51+
- bsonType: String
52+
timestamp:
53+
types:
54+
- bsonType: Date
55+
temp:
56+
types:
57+
- bsonType: Number
4058
- name: Densifiction with Partitions
41-
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/#densifiction-with-partitions
59+
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/#densification-with-partitions
4260
pipeline:
4361
- $densify:
4462
field: altitude
@@ -47,3 +65,17 @@ tests:
4765
range:
4866
bounds: full
4967
step: 200
68+
schema:
69+
coffee:
70+
altitude:
71+
types:
72+
- bsonType: Number
73+
variety:
74+
types:
75+
- bsonType: String
76+
score:
77+
types:
78+
- bsonType: Number
79+
price:
80+
types:
81+
- bsonType: Number

generator/config/stage/documents.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ tests:
2727
- $bucketAuto:
2828
groupBy: $x
2929
buckets: 4
30+
schema:
31+
TestCollection:
32+
x:
33+
types:
34+
- bsonType: Number
3035
- name: Use a $documents Stage in a $lookup Stage
3136
link: https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/#use-a--documents-stage-in-a--lookup-stage
3237
pipeline:
@@ -41,3 +46,11 @@ tests:
4146
name: Palo Alto, CA
4247
- zip_id: 10019
4348
name: New York, NY
49+
schema:
50+
locations:
51+
zip:
52+
types:
53+
- bsonType: Number
54+
name:
55+
types:
56+
- bsonType: String

0 commit comments

Comments
 (0)