hi,
I would like to have a simple field which is the sum of 2 others (auto-calculated) on mongoDB
I saw it's possible to use http://docs.mongodb.org/manual/refer...gregation/sum/
Simple collection :
I would like to have one new field which is total and just a sum of price1 + price2.
How cam I Map this value from mongoDB and create it ?
My only idea is to add a new field with @Transient annotation and make the sum in the setter. But I would like to be able to query this field later :x
I would like to have a simple field which is the sum of 2 others (auto-calculated) on mongoDB
I saw it's possible to use http://docs.mongodb.org/manual/refer...gregation/sum/
Simple collection :
Code:
@Document
public class Bill {
@Id
private String customer;
private int price1;
private int price2;
...
How cam I Map this value from mongoDB and create it ?
My only idea is to add a new field with @Transient annotation and make the sum in the setter. But I would like to be able to query this field later :x