Skip to content

Commit 067ac13

Browse files
committed
Merge branch 'master' of github.com:Automattic/mongoose
2 parents 9a09be1 + d742f4e commit 067ac13

File tree

5 files changed

+50
-18
lines changed

5 files changed

+50
-18
lines changed

.github/workflows/benchmark.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@ name: Benchmark
22
on:
33
pull_request:
44
paths:
5-
- '.github/workflows/benchmark.yml'
6-
- 'package.json'
7-
- 'types/**'
8-
- 'benchmarks/typescript/**'
9-
- 'benchmarks/typescript.js'
5+
- ".github/workflows/benchmark.yml"
6+
- "package.json"
7+
- "types/**"
8+
- "benchmarks/typescript/**"
109
push:
1110
branches:
1211
- master
1312
paths:
14-
- '.github/workflows/benchmark.yml'
15-
- 'package.json'
16-
- 'types/**'
17-
- 'benchmarks/typescript/**'
18-
- 'benchmarks/typescript.js'
13+
- ".github/workflows/benchmark.yml"
14+
- "package.json"
15+
- "types/**"
16+
- "benchmarks/typescript/**"
1917
permissions:
2018
contents: read
2119

@@ -33,6 +31,6 @@ jobs:
3331

3432
- run: npm install
3533

36-
- run: node ./benchmarks/typescript
34+
- run: npx ts-benchmark -p ./benchmarks/typescript/simple -f 17/100000 18 29 32 -b master -g --colors
3735
env:
38-
DB_URL: ${{ secrets.DB_URL }}
36+
DB_URL: ${{ secrets.DB_URL }}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"serve-handler": "6.1.3",
6161
"sinon": "14.0.0",
6262
"stream-browserify": "3.0.0",
63-
"ts-benchmark": "^1.0.2",
63+
"ts-benchmark": "^1.1.5",
6464
"tsd": "0.20.0",
6565
"typescript": "4.7.4",
6666
"uuid": "8.3.2",
@@ -98,8 +98,8 @@
9898
"test-tsd": "node ./test/types/check-types-filename && tsd",
9999
"tdd": "mocha ./test/*.test.js --inspect --watch --recursive --watch-files ./**/*.{js,ts}",
100100
"test-coverage": "nyc --reporter=html --reporter=text npm test",
101-
"ts-benchmark": "node ./benchmarks/typescript.js",
102-
"ts-benchmark-watch": "ts-benchmark -p ./benchmarks/typescript/simple -w ./types -i -s -f 17 18 29 32 -b master"
101+
"ts-benchmark": "ts-benchmark -p ./benchmarks/typescript/simple -f 17/100000 18 29 32",
102+
"ts-benchmark-watch": "ts-benchmark -p ./benchmarks/typescript/simple -w ./types -i -s -f 17/100000 18 29 32 -b master"
103103
},
104104
"main": "./index.js",
105105
"types": "./types/index.d.ts",

test/types/PipelineStage.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,26 @@ const stages3: PipelineStage[] = [
392392
}
393393
}
394394
];
395+
396+
const stages4: PipelineStage[] = [
397+
{
398+
$addFields: {
399+
usersCount: {
400+
$let: {
401+
vars: {
402+
users: { $push: '$user' }
403+
},
404+
in: {
405+
$reduce: {
406+
input: '$users',
407+
initialValue: 0,
408+
in: {
409+
$cond: { if: { $isArray: '$$this' }, then: { $size: '$$this' }, else: '$$this' }
410+
}
411+
}
412+
}
413+
}
414+
}
415+
}
416+
}
417+
];

test/types/expressions.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,13 @@ const nullExpr: Expression = {
193193
const nullNETupleExpr: Expression = {
194194
$ne: ['$name', null]
195195
};
196+
197+
const switchExpr: Expression.Switch = {
198+
$switch: {
199+
branches: [
200+
{ case: { $eq: ['$name', 'Detlef'] }, then: 'Detlef' },
201+
{ case: { $eq: ['$name', 'John'] }, then: 'John' }
202+
],
203+
default: 'Hello'
204+
}
205+
};

types/expressions.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,13 +1067,13 @@ declare module 'mongoose' {
10671067
* - $case
10681068
* - $then
10691069
*/
1070-
$branches: { $case: Expression, then: Expression }[];
1070+
branches: { case: Expression, then: Expression }[];
10711071
/**
10721072
* The path to take if no branch case expression evaluates to true.
10731073
*
10741074
* Although optional, if default is unspecified and no branch case evaluates to true, $switch returns an error.
10751075
*/
1076-
$default: Expression;
1076+
default: Expression;
10771077
};
10781078
}
10791079

@@ -2448,7 +2448,8 @@ declare module 'mongoose' {
24482448
BinaryExpression |
24492449
FunctionExpression |
24502450
ObjectIdExpression |
2451-
ConditionalExpressionOperator;
2451+
ConditionalExpressionOperator |
2452+
Expression.Let;
24522453

24532454
export type ObjectIdExpression =
24542455
TypeExpressionOperatorReturningObjectId;

0 commit comments

Comments
 (0)