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]

Open
#2,587 1 comment 1 reaction 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 30, 2020.

in: aggregation-framework type: bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.