spring-projects / spring-projects/spring-data-mongodb
Is it possible to allow ArithmeticOperators and ProjectionOperation to have date as argument for subtract and add operation ? [DATAMONGO-1675]
@odrotbohm is already working on this.
Since Dec 30, 2020.
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Shiv Veeram opened DATAMONGO-1675 and commented
valueOf method for add & subtract in ArithmeticOperators along with minus & plus methods on ProjectionOperation currently expects Number value, AggregationExpression or a fieldReference.
This is the shell equivalent { $subtract: [ new Date(), "$created" ] }
valueOf("created").subtract(new Date()) is not possible in ArithmeticOperators
We've to use something like valueOf(aggregationOperationContext -> new BasicDBObject("$subtract", Arrays.asList(new Date(), "$created"))) to pass two date values.
Let me know if you need more information.
Arithmetic Operators
http://stackoverflow.com/questions/42840426/mongo-aggregation-using-new-date-as-in-input-to-form-a-aggregationexpression
Projection Operation
http://stackoverflow.com/questions/43647540/spring-data-mongo-db-query-translation
Affects: 1.10 RC1 (Ingalls)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.