How can i make a field in collection incremented automatically ?
@Document
public class Product {
@Id
private BigInteger id;
private String name;
// need to be auto inc
private int version;
i use CrudRepository
public interface ProductRepository extends CrudRepository<Product,BigInteger> {
}
i need to increment version in every creation of new product . example : {_id":"56d21eaeb61595413b3b3db7","name":"Prod 1", "version":"1"} {_id":"56d21eaeb61595413b3b3dbb","name":"Prod 2", "version":"2"}