0

我在firebase数据中有以下结构

订单 -> OrderID -> LocationHistory -> LocationHistoryID -> FieldsData

Orders 和 LocationHistory 是常量,而 OrderID ,LocationHistoryID 是文档 ID

我想知道是否可以生成一个查询以获取存储库中订单的所有 LocationHistory,该存储库扩展 FirestoreReactiveRepository,它应该是 /Orders/10002/LocationHistory/

Belwo 是我目前使用的代码

import org.springframework.cloud.gcp.data.firestore.Document;

import com.google.cloud.firestore.annotation.DocumentId;
import com.google.cloud.firestore.annotation.PropertyName;

import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
@Document(collectionName = "Orders/10002/LocationHistory")
public class LocationHistory
{
    @DocumentId
    private String id;

    private String lat;

    @PropertyName("long")
    private String longitude;

}
4

1 回答 1

0

由于LocationHistory是 的子集合Orders,您应该检索Order将包含LocationHistory.

@Setter
@Getter
@Document(collectionName = "Orders")
public class Order
{
    @DocumentId
    private String id;

    private List<LocationHistory> locationHistory;
}

@Setter
@Getter
public class LocationHistory
{
    @DocumentId
    private String id;

    private String lat;

    @PropertyName("long")
    private String longitude;

}
于 2020-02-27T14:47:07.663 回答