Skip to content

Commit ae55a91

Browse files
committed
add salary Decimal to examples
1 parent 704e906 commit ae55a91

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

examples/user/__tests__/__snapshots__/queriesFromIndex-test.js.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Object {
1212
},
1313
"gender": "ladyboy",
1414
"name": "My Name",
15+
"salaryDecimal": "33333333333333333.33333333333333333",
1516
"someMixed": Object {
1617
"a": 1,
1718
"b": 2,
@@ -35,6 +36,7 @@ Object {
3536
"userById": Object {
3637
"_id": "57bb44dd21d2befb7ca3f001",
3738
"name": "User 1",
39+
"salaryDecimal": "100000000000000000000000.01",
3840
"someMixed": Object {
3941
"a": 123,
4042
"b": Array [
@@ -74,6 +76,7 @@ Object {
7476
},
7577
],
7678
"name": "User 10",
79+
"salaryDecimal": "100000000000000000000000.10",
7780
},
7881
},
7982
}
@@ -100,6 +103,7 @@ Object {
100103
},
101104
],
102105
"name": "User 1",
106+
"salaryDecimal": "100000000000000000000000.01",
103107
},
104108
Object {
105109
"age": 18,
@@ -114,6 +118,7 @@ Object {
114118
},
115119
],
116120
"name": "User 4",
121+
"salaryDecimal": "100000000000000000000000.04",
117122
},
118123
Object {
119124
"age": 32,
@@ -132,6 +137,7 @@ Object {
132137
},
133138
],
134139
"name": "User 7",
140+
"salaryDecimal": "100000000000000000000000.07",
135141
},
136142
Object {
137143
"age": 21,
@@ -146,6 +152,7 @@ Object {
146152
},
147153
],
148154
"name": "User 9",
155+
"salaryDecimal": "100000000000000000000000.09",
149156
},
150157
],
151158
},
@@ -168,6 +175,7 @@ Object {
168175
},
169176
],
170177
"name": "User 4",
178+
"salaryDecimal": "100000000000000000000000.04",
171179
},
172180
},
173181
}
@@ -196,6 +204,7 @@ Object {
196204
},
197205
],
198206
"name": "User 7",
207+
"salaryDecimal": "100000000000000000000000.07",
199208
},
200209
Object {
201210
"age": 21,
@@ -210,6 +219,7 @@ Object {
210219
},
211220
],
212221
"name": "User 9",
222+
"salaryDecimal": "100000000000000000000000.09",
213223
},
214224
],
215225
"pageInfo": Object {

examples/user/data/seed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default async function seed(db: any) {
1717
const data = JSON.parse(fs.readFileSync(`${__dirname}/${file}.json`, 'utf8'));
1818
data.forEach((d, i) => {
1919
data[i]._id = ObjectID.createFromHexString(data[i]._id);
20-
data[i].salary = Decimal128.fromString(data[i].salary);
20+
data[i].salaryDecimal = Decimal128.fromString(data[i].salaryDecimal);
2121
});
2222
if (collectionNames.indexOf(colName) > -1) {
2323
console.log(` '${colName}' dropped`);

examples/user/data/users.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"address": {
2525
"geo": [76.957987, 43.415239]
2626
},
27-
"salary": "100000000000000000000000.01"
27+
"salaryDecimal": "100000000000000000000000.01"
2828
},
2929
{
3030
"_id": "57bb44dd21d2befb7ca3f002",
@@ -42,7 +42,7 @@
4242
"address": {
4343
"geo": [76.932581, 43.241298]
4444
},
45-
"salary": "100000000000000000000000.02"
45+
"salaryDecimal": "100000000000000000000000.02"
4646
},
4747
{
4848
"_id": "57bb44dd21d2befb7ca3f003",
@@ -56,7 +56,7 @@
5656
"phones": ["333-444-666"]
5757
},
5858
"gender": "female",
59-
"salary": "100000000000000000000000.03"
59+
"salaryDecimal": "100000000000000000000000.03"
6060
},
6161
{
6262
"_id": "57bb44dd21d2befb7ca3f004",
@@ -70,7 +70,7 @@
7070
"phones": ["444-444-666"]
7171
},
7272
"gender": "male",
73-
"salary": "100000000000000000000000.04"
73+
"salaryDecimal": "100000000000000000000000.04"
7474
},
7575
{
7676
"_id": "57bb44dd21d2befb7ca3f005",
@@ -84,7 +84,7 @@
8484
"phones": ["555-555-666"]
8585
},
8686
"gender": "female",
87-
"salary": "100000000000000000000000.05"
87+
"salaryDecimal": "100000000000000000000000.05"
8888
},
8989
{
9090
"_id": "57bb44dd21d2befb7ca3f006",
@@ -99,7 +99,7 @@
9999
"phones": ["666-555-333"]
100100
},
101101
"gender": "female",
102-
"salary": "100000000000000000000000.06"
102+
"salaryDecimal": "100000000000000000000000.06"
103103
},
104104
{
105105
"_id": "57bb44dd21d2befb7ca3f007",
@@ -114,7 +114,7 @@
114114
"phones": ["777-555-333"]
115115
},
116116
"gender": "male",
117-
"salary": "100000000000000000000000.07"
117+
"salaryDecimal": "100000000000000000000000.07"
118118
},
119119
{
120120
"_id": "57bb44dd21d2befb7ca3f008",
@@ -128,7 +128,7 @@
128128
"phones": ["888-555-333"]
129129
},
130130
"gender": "female",
131-
"salary": "100000000000000000000000.08"
131+
"salaryDecimal": "100000000000000000000000.08"
132132
},
133133
{
134134
"_id": "57bb44dd21d2befb7ca3f009",
@@ -142,7 +142,7 @@
142142
"phones": ["999-555-333"]
143143
},
144144
"gender": "male",
145-
"salary": "100000000000000000000000.09"
145+
"salaryDecimal": "100000000000000000000000.09"
146146
},
147147
{
148148
"_id": "57bb44dd21d2befb7ca3f010",
@@ -156,6 +156,6 @@
156156
"phones": ["000-555-333"]
157157
},
158158
"gender": "female",
159-
"salary": "100000000000000000000000.10"
159+
"salaryDecimal": "100000000000000000000000.10"
160160
}
161161
]

examples/user/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default {
2626
}
2727
gender
2828
age
29+
salaryDecimal
2930
}
3031
}
3132
`,
@@ -45,6 +46,7 @@ export default {
4546
}
4647
gender
4748
age
49+
salaryDecimal
4850
}
4951
}
5052
`,
@@ -64,6 +66,7 @@ export default {
6466
}
6567
gender
6668
age
69+
salaryDecimal
6770
}
6871
}
6972
`,
@@ -83,6 +86,7 @@ export default {
8386
address {
8487
geo
8588
}
89+
salaryDecimal
8690
}
8791
8892
distance_100_km: userMany(filter: {
@@ -96,6 +100,7 @@ export default {
96100
address {
97101
geo
98102
}
103+
salaryDecimal
99104
}
100105
}
101106
`,
@@ -108,6 +113,7 @@ export default {
108113
_id
109114
name
110115
someMixed
116+
salaryDecimal
111117
}
112118
}
113119
`,
@@ -131,7 +137,8 @@ mutation {
131137
a: 1,
132138
b: 2,
133139
c: [ 1, 2, 3, true, false, { sub: 1 }]
134-
}
140+
},
141+
salaryDecimal: "33333333333333333.33333333333333333"
135142
}) {
136143
recordId
137144
record {
@@ -143,6 +150,7 @@ mutation {
143150
phones
144151
}
145152
someMixed
153+
salaryDecimal
146154
}
147155
}
148156
}
@@ -164,6 +172,7 @@ mutation {
164172
}
165173
gender
166174
age
175+
salaryDecimal
167176
}
168177
count
169178
pageInfo {

examples/user/models/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const UserSchema: Schema<UserDoc> = new Schema(
5555
type: Schema.Types.Mixed,
5656
description: 'Some dynamic data',
5757
},
58-
salary: {
58+
salaryDecimal: {
5959
type: Schema.Types.Decimal128,
6060
index: true,
6161
},

0 commit comments

Comments
 (0)