第一次发布所以任何提示将不胜感激。我正在尝试使用 REST api 在 StructuredQuery 中设置一个 'orderBy' to firestore。如果不使用 orderBy 字段,请注意我的查询确实有效,这也很有帮助。
我的查询如下所示:
var collection = "testing";
var Query = { //body of the http request
"structuredQuery": {
"from": {
"collectionId":collection,
"allDescendants":true
},
"orderBy": {
"field": {
"fieldPath" : "uploaded"
},
"direction" : "DESCENDING"
},
"limit": 1
},
"newTransaction": {}
}
var urlPOST = "https://firestore.googleapis.com/v1beta1/projects/"+id+"/databases/"+database+"/documents:runQuery?key="+key;
var optPOST = { //http header
'method' : 'post',
'contentType' : 'application/json',
'muteHttpExceptions': true,
'payload': JSON.stringify(Query)
};
var response = UrlFetchApp.fetch(urlPOST, optPOST);
Run Code Online (Sandbox Code Playgroud)
从这个请求我得到:
"error": {
"code": …Run Code Online (Sandbox Code Playgroud)