Java MongoRepository方法,返回项目位置和特定点之间的距离
我有两个实体:Java MongoRepository方法,返回项目位置和特定点之间的距离,java,spring,mongodb,spring-data,spring-mongo,Java,Spring,Mongodb,Spring Data,Spring Mongo,我有两个实体: @Document(collection = "users") public class User implements Serializable { @Id private String id; } @Document(collection = "items") public class Item implements Serializable { @Id private String id; @DBRef(lazy = tru
@Document(collection = "users")
public class User implements Serializable {
@Id
private String id;
}
@Document(collection = "items")
public class Item implements Serializable {
@Id
private String id;
@DBRef(lazy = true)
private User user;
@GeoSpatialIndexed(type = GeoSpatialIndexType.GEO_2DSPHERE)
private GeoJsonPoint location;
}
我想找到引用特定用户的所有项目,并以某种方式返回点和项目位置之间的距离
public interface ItemRepository extends MongoRepository<Item, String> {
Page<Item> findByUserId(String userId, Pageable pageable);
}
public interface ItemRepository扩展了MongoRepository{
pagefindbyuserid(字符串userId,Pageable-Pageable);
}
如何更改findByUserId
method声明以同时返回项目位置和某个点之间的距离(可能可以作为参数传递)
我尝试过GeoPage,但没有成功