Skip to content

Is it possible to allow ArithmeticOperators and ProjectionOperation to have date as argument for subtract and add operation ? [DATAMONGO-1675] #2587

Open
@spring-projects-issues

Description

@spring-projects-issues

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions