-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Milestone
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the issue has not already been raised
Running:
- Mongoose 6.4.1
- Typescript 4.7.4
- Node 14.19.1
Issue
This new update has messed up a log of my aggregation typings (like others).
1. Add DateExpressionOperatorReturningNumber to NumberExpression
This doesn't work currently, but it should. I believe it was forgotten:
const a: Expression = { $subtract: [
{ $dayOfWeek: new Date() } as Expression.DayOfWeek, // errors
2
] };2. Some stages and operators specify "Expressions" when they can take values as well
This breaks quite a few things ($addToSet as well):
const a: Expression.Reduce = {
$reduce: {
input: '$values',
initialValue: { depth: -1 }, // errors
in: {
depth: '$$this.depth' // errors
}
}
};
const b: Expression.Reduce = {
$reduce: {
input: '$values',
initialValue: 0, // errors
in: { $add: ['$$value', '$$this'] }
}
};
const c: PipelineStage.Set = {
$set: {
child: {
foo: 'bar' // errors
},
friend: new ObjectId() // errors
}
};
const a: Expression.ToInt = { $toInt: 2.5 }; // errors3. AddToSet requires ArrayExpression
According to the docs it just takes an "expression" ( https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/ ).
4. Cond doesn't allow nested Conds
...because it is too strict on the first requirement being a BooleanExpression. I think switching most operators to accept a ConditionalExpressionOperator (with a <T> or otherwise) would help a lot, because IfNull is also throwing things.
Otherwise, reintroducing the old Pipeline type and/or having a more flexible Pipeline type in parallel, if we wanted/needed less strict checks would be great.
Davies-Owen, skrtheboss, jbarmash and Yooooomi
Metadata
Metadata
Assignees
Labels
No labels