文档父名称在Firestore PHP SDK的索引53处缺少集合id
我试图在Google Firestore中查询子集合。我的目标是在1970年1月1日之后使用startDate(存储在Google Firestore的时间戳数据类型中)获取所有记录 我正在使用GoogleCloud Firestore PHP SDK来实现这一点: 这是我的密码:文档父名称在Firestore PHP SDK的索引53处缺少集合id,php,firebase,google-cloud-firestore,Php,Firebase,Google Cloud Firestore,我试图在Google Firestore中查询子集合。我的目标是在1970年1月1日之后使用startDate(存储在Google Firestore的时间戳数据类型中)获取所有记录 我正在使用GoogleCloud Firestore PHP SDK来实现这一点: 这是我的密码: $config = array( "projectId" => "xxx-test", "keyFile" => json_decode(file_get_con
$config = array(
"projectId" => "xxx-test",
"keyFile" => json_decode(file_get_contents("/xxx/firebase_auth.json"), true)
);
$firestore = new FirestoreClient($config);
$collection = $firestore->collection("/clients/-LXXXXXX/trips");
$query = $collection->where("startDate", ">=", new Timestamp(new \DateTime("Thu Jan 1st 1970")));
var_dump($query->documents());
我得到了这个错误:
Exception 'Google\Cloud\Core\Exception\BadRequestException' with message
'{
"message": "Document parent name \"projects\/xxx-test\/databases\/(default)\/documents\/\/clients\/-LXXXXXX\" lacks a collection id at index 53.",
"code": 3,
"status": "INVALID_ARGUMENT",
"details": []
}'
非常感谢您的帮助。收集路径不是这样工作的:
$collection = $firestore->collection("clients")->document("-LXXXXXX")->collection("trips");
集合路径不是这样工作的:
$collection = $firestore->collection("clients")->document("-LXXXXXX")->collection("trips");